PDA

View Full Version : Parser: Lexical Errors May Cause Crash



ZoriaRPG
06-14-2016, 02:13 PM
Moosh reported this to me yesterday:

If a script contains a lexical error (tested with CHAR_DOUBLEQUOTE) and the script is over a certain length (greater than 16.4 KB), ZC will crash while parsing it.

I've tested this, and can confirm it. The easiest fix would possibly be to halt the compiler on a lexical error, which I think would be best in general; but finding the cause of this would probably be good.

Affects 2.50.2; tested with Win 7.

Tamamo
07-13-2016, 12:48 AM
Wait? ZC Doesn't parse scripts, Do you mean ZQuest?

Gleeok
07-13-2016, 02:11 AM
I've never been able to reproduce any of these compiler crashes over the years.

Can you try running it in the debugger next time you test it?

Tamamo
07-13-2016, 02:43 AM
Me neither, it's quite weird. I do get lexical errors from double quotes some times though. "Which you shouldn't it parses as an array of shorts if you set it up as such"

ZoriaRPG
07-13-2016, 03:55 AM
I'm going to force a compiler halt for lexical errors. That's the only easy solution, and IMO no lexing error should be suppressed, except truncation; as Joe user won't even notice them in their rush to compile.

I could just add SINGLEQUOTE as a halt though, or better still, make ' return the same as DOUBLEQUOTE so that we can just use the char to input QUOTEDSTRINGS. (i.e. Both ' and " would be read the same way.)

Tamamo: Aye, I meant ZQuest.

Tamamo
07-13-2016, 10:35 AM
Unfortunately the way it's set up now, single quotes are for characters I think, and double quotes for strings. At least I think that's it.

Saffith
07-13-2016, 03:03 PM
Has this only been confirmed with double quotation marks? That's the only thing I'm seeing a problem with. That would be from trying to read everything after it as a single string; it wouldn't even get as far as detecting an error.

Edit: Nope, I'm wrong. It was crashing printing the error. Considering this fixed unless someone can confirm another cause.

ZoriaRPG
07-14-2016, 03:32 AM
Has this only been confirmed with double quotation marks? That's the only thing I'm seeing a problem with. That would be from trying to read everything after it as a single string; it wouldn't even get as far as detecting an error.

Edit: Nope, I'm wrong. It was crashing printing the error. Considering this fixed unless someone can confirm another cause.

Can you elaborate on the exact cause of this, please, and what you changed?



Unfortunately the way it's set up now, single quotes are for characters I think, and double quotes for strings. At least I think that's it.

They return SINGLECHAR, so, I may as well leave them be, but making the compiler halt on lexing errors is just common sense.

Saffith
07-14-2016, 02:00 PM
sprintf overflow. The error message buffer only has room for 511 characters.