Test case:
int score_image(string image, int r, int g, int b) {return 42;} array(int) getpixel() {return ({1, 2, 3});}
int main(int argc, array(string) argv) { if (argc < 2) exit(0, "All good! Try again with -DBOOM for a segfault.\n"); array images = ({"foo", "bar", "quux"}); for (int x = 0; x < 10; ++x) //Without the loop, no boom { #ifdef BOOM array pixel = getpixel(); array(int) scores = score_image(images[*], @pixel); //Segfault #else [int r, int g, int b] = getpixel(); array(int) scores = score_image(images[*], r, g, b); //But avoiding @ works. #endif } }
It's fine with either [*] or @pixel, and it's even fine with both, as long as it's not in a loop. But put all three together, and the interpreter segfaults before executing a single line of actual code, which I suspect means an issue at the compilation stage. (Can be triggered identically by casting "boom.pike" to program too.)
Tested with the latest master branch, and with 8.0.735.
No idea where to start looking for the cause, but it's a completely consistent crash.
ChrisA
The crash is on this line:
0x00000001000a43b8 in do_docode2 (n=0x10048eb30, flags=<optimized out>, flags@entry=0) at /home/marcus/Pike/8.1/src/docode.c:1174 1174 current_label->cleanups->cleanup = do_pop_to_mark;
with current_label->cleanups == NULL.
If pike is built with PIKE_DEBUG, you get this fatal instead:
/home/marcus/Pike/8.1/src/docode.c:1167: Fatal error: F_PUSH_ARRAY unexpected in this context. Backtrace at time of fatal: -:1: PikeCompiler("", UNDEFINED, -1, -1, target, UNDEFINED)->compile() -:1: DefaultCompilerEnvironment->compile(PikeCompiler("", UNDEFINED, -1, -1, ta rget, UNDEFINED)) /usr/local/pike/8.1.13/lib/master.pike:655: compile_string("int score_image(string image, int r, int g, int b) {return 42;}\narray(int) getpixel() {return ({1, 2, 3});}\n\nin"+[487]+"ng @ work s.\n #endif\n }\n}\n","/tmp/chris.pike",UNDEFINED,/tmp/chris,0,U NDEFINED)
So the crash is in the compiler proper, not in the execution of the program.
The crash is on this line:
[...]
If pike is built with PIKE_DEBUG, you get this fatal instead:
[...]
So the crash is in the compiler proper, not in the execution of the program.
Thanks for the report, test case and investigation.
Fixed the code generator in Pike 8.0 and master.
/grubba
pike-devel@lists.lysator.liu.se