foralex / picoc

Automatically exported from code.google.com/p/picoc
0 stars 0 forks source link

Issue 192 revisited -- still broken in interactive mode. #193

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
r605 was intended to address issue 192, but does not do so for interactive mode.

What steps will reproduce the problem?
1. Enter the following at the command line / within picoc interactive mode:
Marks-MacBook-Air:picoc-608 heilpern$ ./picoc -i
starting picoc v2.2 beta r608
picoc> #include <stdio.h>
picoc> 
     > void printArray(void) {
     > #define SIZE 10
     >     int array[SIZE] = {5, 4, 3, 9, 1, 8, 6, 7, 5, 2};
     >     printf("4: %d\n", array[4]);
     > }
picoc> printArray();
Segmentation fault: 11

What is the expected output? What do you see instead?
Expected output is "4: 1" rather than the crash/segfault.

I've verified that running the test case for this change does in fact work; the 
crash only occurs from interactive mode.

What version of the product are you using? On what operating system?
r608 / OS X Mavericks

Original issue reported on code.google.com by m...@heilpern.com on 3 Mar 2014 at 9:31

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
This crash happens at the same line of code as bug #190 and for the same 
reason: pc->InteractiveCurrentLine is null. It's another re-entrancy issue. 
This time, while executing printArray(), picoc is re-evaluating the #define. 
This, of course, is not how a compiler would handle a preprocessor statement. 

It's also bad style to put a #define inside a function, but it's legal C.

Original comment by goo...@LoadAccumulator.com on 5 Aug 2015 at 2:42

GoogleCodeExporter commented 8 years ago
Although this crash is similar to bug #190, the fix that worked for 190 
(preserving the lexer state) needs to be applied at a different line of code. 
I'm not sure exactly where, but it's somewhere in the call stack for the crash.

Original comment by goo...@LoadAccumulator.com on 17 Aug 2015 at 3:11