JS_DefineFunctions Does Not Work in 32bit Build (SegFaults)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
xulrunner-1.9 (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Calls to JS_DefineFunctions do not work in 32bit builds, sometimes leading to segmentation faults. Here is a sample backtrace from gdb (when it segfaulted):
#0 0x4011c25b in strlen () from /lib/tls/
#1 0x4082dd98 in JS_DefineFunction (cx=0x81f1eb0, obj=0x81f5830, name=0x1 <Address 0x1 out of bounds>,
call=0x4082ee20 <js_generic_
#2 0x4082ebb7 in JS_DefineFunctions (cx=0x81f1eb0, obj=0x81f5938, fs=0x4093852c) at jsapi.c:3708
#3 0x4092fb44 in MY_InitFunctions (cx=0x81f1eb0) at core.c:1081
Some more investigation has show that JS_DefineFunctions loops over the array that it is passed and calls JS_DefineFunction. The first call to JS_DefineFunction works just fine. It is the second call where the problem occurs.
Specifically, it appears to be a bug in the way the JSFunctionSpec is defined (https:/
When the following JSFunctionSpec is used, you get a segfault on the 32bit build (but not on the 64bit build):
static JSFunctionSpec global_funcs[] = {
{"a", TestFunc, 1, 0, 1},
{"b", TestFunc, 1, 0, 1},
{NULL,
};
I have attached a small sample program the demonstrates this bug. It can be compiled with the following comand:
gcc -I/usr/
Note: I have compiled SpiderMonkey from source and installed it as a separate library. This fixed the problem, so something is definitely wrong with the binary being distributed with thsi package.