Page 1 of 1

ED_LoadFromFile ie Needle in the Haystack

Posted: Tue Sep 22, 2015 4:02 pm
by r00k
So, I'm getting a crash on only two maps, one being jrdm2 "Foot Massage".

It spits out a "ED_LoadFromFile: found %s when expecting {", although running through the debugger i get no error, yet running the /debug/glQrack.exe from there i do.

Is there a particular place i should be double checking, if com_token is getting stomped on? Or an easier way to find this bug other than diff'ing 100 lines of code?

It seems this bug crept in way back into v1.90 from 2011, with the last non bugged version at 1.85, which i cant even run on windows 10 :(

Re: ED_LoadFromFile ie Needle in the Haystack

Posted: Tue Sep 22, 2015 5:35 pm
by Spike
make sure you're not triggering a stack overflow or anything.
(try setting msvc's c/c++->code generation->basic type checks to both, or run it in valgrind, or both)

by using an over-long field name, a map could get a nice stack overflow exploit. com_parse can also overflow com_token, which would give a nice large block of memory at a known location... it'd be pretty easy, if you know your asm well enough to avoid nulls.

Print out the stuff you've parsed so far (pipe the output of your engine through cat or to a file and you should be able to see any stdout printed via con_printf->sys_printf->printf even in windows). check which part of the file it reached and if that part of the file has any weird chars or over-long tokens or anything weird like that.

Re: ED_LoadFromFile ie Needle in the Haystack

Posted: Wed Sep 23, 2015 1:47 am
by r00k
Thanks for the quick reply and insight.
Its been many moons since i've done any work on the engine and as a hobbiest code monkey i hate leaving bugs unattended :o

Re: ED_LoadFromFile ie Needle in the Haystack

Posted: Thu Sep 24, 2015 6:48 am
by r00k
ya i did a con_printf and after each {...} there was some wonky chars, i assume were comments or some junk from the compiler of that time.
i just added

Code: Select all

		if (com_token[0] != '{')
		{
			com_token[0] = 0;
		//	Host_Error ("ED_LoadFromFile: found %s when expecting {",com_token);
		}
and the map loads now.
is there any side effect of doing this??

Re: ED_LoadFromFile ie Needle in the Haystack

Posted: Thu Sep 24, 2015 6:59 am
by r00k
edit:
wait somehow i ran the =wrong exe, that didnt help.



side note: this forum has no edit button.
i guess we are engraving into marble...

Re: ED_LoadFromFile ie Needle in the Haystack

Posted: Thu Sep 24, 2015 7:08 am
by r00k
hmm man coding after 2am and 2many beers

i guess this works,

Code: Select all

		if (com_token[0] != '{')
		{
			com_token[0] = 0;			
			continue;
		}
dunno dont care, hehe!