nimble-code / Cobra

An interactive (fast) static source code analyzer
139 stars 31 forks source link

is it possible to increase `MAXYYTEXT` if file size is big, programmatically? #42

Closed yilmazdurmaz closed 2 years ago

yilmazdurmaz commented 2 years ago

I have bumped into this assertion issue where Cobra stops at the beginning:

cobra: cobra_lex.c:450: p_comment: Assertion `i < MAXYYTEXT' failed

the file is only 107356 bytes long but has 2140 lines and 7287 tokens in it.

I have increased MAXYYTEXT to 3072 and recompiled Cobra to get it run. So it is possible to fix by this way.

But I wonder if, instead of failing, it is possible to increase this value in steps dynamically if the file size is above some thresholds, or how hard would it be to do so.

nimble-code commented 2 years ago

it's a good suggestion I'll look into it

nimble-code commented 2 years ago

the MAXYYTEXT macro is sized to handle the maximum number of characters that could be on a single line of input. so the value 2048 is reasonable, but in some hopefully rare cases it could be insufficient. the case you hit (line 450 in cobra_lex.c) was actually in a line with a comment -- given that comments are by default not turned into tokens anyway, it doesn't make sense to first give the full comment to the lexer and then throw it away anyway -- so i'll fix it so that this assertions wouldn't be the showstopper anymore. the input buffer is passed around in a few places so changing it into a dynamically allocated array would take a bit more work. i'll hold off on that one for now (until there's nothing else to fix or improve!) thanks for reporting this though!

yilmazdurmaz commented 2 years ago

Fair enough, Thanks :) Maybe, in time, I will have enough knowledge to help code such parts.