There is no way (AFAIK) to check the number of arguments passed (except when explicitly specifying variable number of arguments).
query_num_arg does that. You can also check if an argument has zero_type set.
Do you get a segfault in get_all_args?
Not really - somewhere outside, I guess during stack unwinding or something like this. At least, it happens while executing get_all_args(). The backtrace:
You mean, the bug happens while executing get_all_args, where the bug is that it doesn't throw a pike error, I presume. You're very welcome to whip out gdb and find out why the check for too few arguments on line 381 in src/module_support.c doesn't work.
Also, compiling pike with --with-rtldebug and without --without-cdebug (or without stripping) helps quite a lot in tracking down bugs.
/ Martin Stjernholm, Roxen IS
Previous text:
2004-02-27 23:27: Subject: Re: Problem with function prototypes
On Fri, Feb 27, 2004 at 05:25:09PM +0100, Martin Stjernholm, Roxen IS @ Pike developers forum wrote:
And even if that is added, runtime checks would frequently be necessary anyway since 0 is valid for all types (except void),
Except that there is a slight difference - function was called (intentionally) with all 0 as arguments, or bu accident (i.e. without any arguments).
There is no way (AFAIK) to check the number of arguments passed (except when explicitly specifying variable number of arguments).
Do you get a segfault in get_all_args?
Not really - somewhere outside, I guess during stack unwinding or something like this. At least, it happens while executing get_all_args(). The backtrace:
#0 0x401b276f in malloc_consolidate () from /lib/i686/libc.so.6 #1 0x401b2127 in _int_malloc () from /lib/i686/libc.so.6 #2 0x401b106c in malloc () from /lib/i686/libc.so.6 #3 0x080e4425 in debug_xalloc () #4 0x080df21d in init_mapping () #5 0x080df391 in debug_allocate_mapping () #6 0x080e278b in f_aggregate_mapping () #7 0x081896fd in file_tcgetattr () #8 0x0807712a in low_mega_apply () #9 0x08074170 in eval_instruction () #10 0x080784c8 in o_catch () #11 0x08070d45 in eval_instruction () #12 0x080783c0 in mega_apply () #13 0x080e5bf7 in call_pike_initializers () #14 0x080e5e11 in parent_clone_object () #15 0x08077538 in low_mega_apply () #16 0x080741f2 in eval_instruction () #17 0x080783c0 in mega_apply () #18 0x08079320 in apply () #19 0x080deb20 in main ()
get_all_args() was called when there were no arguments (it expected string).
The backtrace looks strange by itself...
Sure I can workaround this (don't use get_all_args() or check the number of arguments) - but anyway, there is a problem, and this function is supposed to do all this dirty job... :)
Regards, /Al
/ Brevbäraren