Open GoogleCodeExporter opened 9 years ago
The problem occurs whenever a #include statement is entered in interactive
mode. The crash occurs in LexCopyTokens at the line:
if (EndParser->Pos >= StartParser->Pos && EndParser->Pos <
&pc->InteractiveCurrentLine->Tokens[pc->InteractiveCurrentLine->NumBytes])
because pc->InteractiveCurrentLine is null. The root of the problem appears to
be that Picoc_struct has global lexer data, but when you're in immediate mode
and you #include, you're re-entering the lexer.
I believe I've solved this.
In include.c, in void IncludeFile(Picoc *pc, char *FileName), replace:
PicocPlatformScanFile(pc, FileName);
with code that saves the global values, sets them to NULL, then restores them
afterwards:
{
struct TokenLine *head = pc->InteractiveHead, *tail = pc->InteractiveTail, *line = pc->InteractiveCurrentLine;
pc->InteractiveHead = pc->InteractiveTail = pc->InteractiveCurrentLine = NULL;
PicocPlatformScanFile(pc, FileName);
pc->InteractiveHead = head;
pc->InteractiveTail = tail;
pc->InteractiveCurrentLine = line;
}
Original comment by goo...@LoadAccumulator.com
on 5 Aug 2015 at 2:30
This is fixed on my fork at https://github.com/galacticstudios/picoc
Original comment by goo...@LoadAccumulator.com
on 17 Aug 2015 at 3:09
Original issue reported on code.google.com by
m...@heilpern.com
on 10 Feb 2014 at 4:49