Yesterday I stumbled on a segfault:
allocate (17, UNDEFINED);
Segmentation fault (core dumped)
It's fixed now, but the problem is bigger than this particular case. The thing is that get_all_args doesn't always set the optional arguments - that happens both when the real arguments run out and when UNDEFINED is sent as a real argument.
There's a lot of code that uses get_all_args and still looks at the arg counter to see whether an argument has been given. E.g. allocate() was like this:
PMOD_EXPORT void f_allocate(INT32 args) { INT_TYPE size; struct array *a; struct svalue *init;
get_all_args("allocate", args, "%+.%*", &size, &init); /.../ if(args>1) { /.../ copy_svalues_recursively_no_free(a->item+e, init, 1, 0); /.../
Even though there's more than one arg on the stack, it's not certain that init has a defined value there. I went through the pike source and fixed this at a number of places, so it seems to be a common misconception.
So the bottom line is, please remember to _always_ initialize the variables for optional arguments when you use get_all_args.
pike-devel@lists.lysator.liu.se