Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 366729 - dev-db/couchdb / dev-lang/spidermonkey-1.8.2.x / net-libs/xulrunner-2.0 - couchjs segfaults
Summary: dev-db/couchdb / dev-lang/spidermonkey-1.8.2.x / net-libs/xulrunner-2.0 - co...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: x86 Linux
: Normal normal with 1 vote (vote)
Assignee: Dirkjan Ochtman (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on: 361937
Blocks:
  Show dependency tree
 
Reported: 2011-05-10 09:50 UTC by Tilo Prütz
Modified: 2012-07-04 07:48 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
couchdb 1.1.0 patch for spidermonkey 1.8.5 (js185.patch,13.03 KB, patch)
2011-10-10 06:03 UTC, Tilo Prütz
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tilo Prütz 2011-05-10 09:50:29 UTC
couchdb depends on spidermonkey(-1.9) which installs fine beside xulrunner(-2). But when running couchjs it does not use the libmozjs.so from /usr/lib (spidermonkey) but from /usr/lib/xulrunner-2.0. Since the libmozjs-API has changed the program crashes with a segfault.

Reproducible: Always

Steps to Reproduce:
1. Install xulrunner-2 (e.g. for firefox-4)
2. Install couchdb (depends on spidermonkey)
3. Try to run couchjs with any JS file
Actual Results:  
crash with segfault and core dump:

Core was generated by `/usr/lib/couchdb/bin/couchjs test.js'.
Program terminated with signal 11, Segmentation fault.
#0  getNext (cx=0x808fd38, jsclasp=<value optimized out>, proto=0x0, parent=0x0) at jsgc.h:648
648	jsgc.h: Datei oder Verzeichnis nicht gefunden.
	in jsgc.h
(gdb) bt
#0  getNext (cx=0x808fd38, jsclasp=<value optimized out>, proto=0x0, parent=0x0) at jsgc.h:648
#1  NewFinalizableGCThing<JSObject> (cx=0x808fd38, jsclasp=<value optimized out>, proto=0x0, parent=0x0) at jsgcinlines.h:122
#2  js_NewGCObject (cx=0x808fd38, jsclasp=<value optimized out>, proto=0x0, parent=0x0) at jsgcinlines.h:139
#3  NewObject<false, false> (cx=0x808fd38, jsclasp=<value optimized out>, proto=0x0, parent=0x0) at jsobjinlines.h:1081
#4  NewNonFunction<(js::WithProto::e)0> (cx=0x808fd38, jsclasp=<value optimized out>, proto=0x0, parent=0x0) at jsobjinlines.h:1131
#5  JS_NewObject (cx=0x808fd38, jsclasp=<value optimized out>, proto=0x0, parent=0x0) at jsapi.cpp:3110
#6  0x0804aaec in main (argc=2, argv=0xbf9ddcc4) at couch_js/main.c:294


Expected Results:  
No crash but a working couchjs.

It seems that the couchdb does not compile against xulrunner-2. When I tried it fails on compiling due to changed API with:

[…]
Making all in priv
make[4]: Entering directory `/var/tmp/portage/dev-db/couchdb-1.0.2-r1/work/apache-couchdb-1.0.2/src/couchdb/priv'
/bin/sh ../../../libtool  --tag=CC   --mode=compile i686-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../../..   -D_XOPEN_SOURCE -L/usr/lib/xulrunner-2.0 -L/usr/local/lib -L/opt/local/lib -I/usr/lib/erlang/usr/include -I/usr/include/xulrunner-2.0 -DXP_UNIX   -I/usr/include  -L/usr/lib  -O2 -march=core2 -pipe -g -MT couch_icu_driver_la-couch_icu_driver.lo -MD -MP -MF .deps/couch_icu_driver_la-couch_icu_driver.Tpo -c -o couch_icu_driver_la-couch_icu_driver.lo `test -f 'icu_driver/couch_icu_driver.c' || echo './'`icu_driver/couch_icu_driver.c
cp spawnkillable/couchspawnkillable.sh couchspawnkillable
i686-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../../..   -D_XOPEN_SOURCE -L/usr/lib/xulrunner-2.0 -L/usr/local/lib -L/opt/local/lib -I/usr/lib/erlang/usr/include -I/usr/include/xulrunner-2.0 -DXP_UNIX   -D_BSD_SOURCE  -O2 -march=core2 -pipe -g -MT couchjs-http.o -MD -MP -MF .deps/couchjs-http.Tpo -c -o couchjs-http.o `test -f 'couch_js/http.c' || echo './'`couch_js/http.c
i686-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../../..   -D_XOPEN_SOURCE -L/usr/lib/xulrunner-2.0 -L/usr/local/lib -L/opt/local/lib -I/usr/lib/erlang/usr/include -I/usr/include/xulrunner-2.0 -DXP_UNIX   -D_BSD_SOURCE  -O2 -march=core2 -pipe -g -MT couchjs-main.o -MD -MP -MF .deps/couchjs-main.Tpo -c -o couchjs-main.o `test -f 'couch_js/main.c' || echo './'`couch_js/main.c
chmod +x couchspawnkillable
i686-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../../..   -D_XOPEN_SOURCE -L/usr/lib/xulrunner-2.0 -L/usr/local/lib -L/opt/local/lib -I/usr/lib/erlang/usr/include -I/usr/include/xulrunner-2.0 -DXP_UNIX   -D_BSD_SOURCE  -O2 -march=core2 -pipe -g -MT couchjs-utf8.o -MD -MP -MF .deps/couchjs-utf8.Tpo -c -o couchjs-utf8.o `test -f 'couch_js/utf8.c' || echo './'`couch_js/utf8.c
cp stat_descriptions.cfg.in stat_descriptions.cfg
libtool: compile:  i686-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../../.. -D_XOPEN_SOURCE -L/usr/lib/xulrunner-2.0 -L/usr/local/lib -L/opt/local/lib -I/usr/lib/erlang/usr/include -I/usr/include/xulrunner-2.0 -DXP_UNIX -I/usr/include -L/usr/lib -O2 -march=core2 -pipe -g -MT couch_icu_driver_la-couch_icu_driver.lo -MD -MP -MF .deps/couch_icu_driver_la-couch_icu_driver.Tpo -c icu_driver/couch_icu_driver.c  -fPIC -DPIC -o .libs/couch_icu_driver_la-couch_icu_driver.o
couch_js/main.c: In Funktion »evalcx«:
couch_js/main.c:62: Warnung: Zuweisung erzeugt Zeiger von Ganzzahl ohne Typkonvertierung
couch_js/main.c: Auf höchster Ebene:
couch_js/main.c:251: Warnung: Initialisierung von inkompatiblem Zeigertyp
couch_js/main.c:251: Warnung: Elementüberschreitung in struct-Initialisierung
couch_js/main.c:251: Warnung: (nahe der Initialisierung für »global_functions[0]«)
couch_js/main.c:252: Warnung: Initialisierung von inkompatiblem Zeigertyp
couch_js/main.c:252: Warnung: Elementüberschreitung in struct-Initialisierung
couch_js/main.c:252: Warnung: (nahe der Initialisierung für »global_functions[1]«)
couch_js/main.c:253: Warnung: Initialisierung von inkompatiblem Zeigertyp
couch_js/main.c:253: Warnung: Elementüberschreitung in struct-Initialisierung
couch_js/main.c:253: Warnung: (nahe der Initialisierung für »global_functions[2]«)
couch_js/main.c:254: Warnung: Initialisierung von inkompatiblem Zeigertyp
couch_js/main.c:254: Warnung: Elementüberschreitung in struct-Initialisierung
couch_js/main.c:254: Warnung: (nahe der Initialisierung für »global_functions[3]«)
couch_js/main.c:255: Warnung: Initialisierung von inkompatiblem Zeigertyp
couch_js/main.c:255: Warnung: Elementüberschreitung in struct-Initialisierung
couch_js/main.c:255: Warnung: (nahe der Initialisierung für »global_functions[4]«)
couch_js/main.c:256: Warnung: Initialisierung von inkompatiblem Zeigertyp
couch_js/main.c:256: Warnung: Elementüberschreitung in struct-Initialisierung
couch_js/main.c:256: Warnung: (nahe der Initialisierung für »global_functions[5]«)
couch_js/main.c:257: Warnung: Elementüberschreitung in struct-Initialisierung
couch_js/main.c:257: Warnung: (nahe der Initialisierung für »global_functions[6]«)
couch_js/main.c:266: Warnung: Initialisierung von inkompatiblem Zeigertyp
couch_js/utf8.c: In Funktion »enc_string«:
couch_js/utf8.c:132: Warnung: Zuweisung erzeugt Zeiger von Ganzzahl ohne Typkonvertierung
couch_js/http.c:309: Warnung: Initialisierung von inkompatiblem Zeigertyp
couch_js/http.c:318: Warnung: Initialisierung von inkompatiblem Zeigertyp
couch_js/http.c:323: Warnung: Initialisierung von inkompatiblem Zeigertyp
couch_js/http.c:323: Warnung: Elementüberschreitung in struct-Initialisierung
couch_js/http.c:323: Warnung: (nahe der Initialisierung für »CouchHTTPFunctions[0]«)
couch_js/http.c:324: Warnung: Initialisierung von inkompatiblem Zeigertyp
couch_js/http.c:324: Warnung: Elementüberschreitung in struct-Initialisierung
couch_js/http.c:324: Warnung: (nahe der Initialisierung für »CouchHTTPFunctions[1]«)
couch_js/http.c:325: Warnung: Initialisierung von inkompatiblem Zeigertyp
couch_js/http.c:325: Warnung: Elementüberschreitung in struct-Initialisierung
couch_js/http.c:325: Warnung: (nahe der Initialisierung für »CouchHTTPFunctions[2]«)
couch_js/http.c:326: Warnung: Elementüberschreitung in struct-Initialisierung
couch_js/http.c:326: Warnung: (nahe der Initialisierung für »CouchHTTPFunctions[3]«)
couch_js/http.c: In Funktion »install_http«:
couch_js/http.c:346: Warnung: Übergabe des Arguments 5 von »JS_InitClass« von inkompatiblem Zeigertyp
/usr/include/xulrunner-2.0/jsapi.h:2108: Anmerkung: expected »JSNative« but argument is of type »JSBool (*)(struct JSContext *, struct JSObject *, uintN,  jsval *, jsval *)«
mv -f .deps/couchjs-utf8.Tpo .deps/couchjs-utf8.Po
mv -f .deps/couchjs-main.Tpo .deps/couchjs-main.Po
mv -f .deps/couch_icu_driver_la-couch_icu_driver.Tpo .deps/couch_icu_driver_la-couch_icu_driver.Plo
/bin/sh ../../../libtool --tag=CC   --mode=link i686-pc-linux-gnu-gcc -I/usr/include  -L/usr/lib  -O2 -march=core2 -pipe -g -module -avoid-version -I/usr/include  -L/usr/lib   -L/usr/lib/xulrunner-2.0 -L/usr/local/lib -L/opt/local/lib -I/usr/lib/erlang/usr/include -I/usr/include/xulrunner-2.0 -DXP_UNIX  -lm -Wl,-O1 -Wl,--as-needed -o couch_icu_driver.la -rpath /usr/lib/couchdb/erlang/lib/couch-1.0.2/priv/lib couch_icu_driver_la-couch_icu_driver.lo -licuuc -licudata -licui18n -L/usr/lib/xulrunner-2.0 -L/usr/local/lib -L/opt/local/lib -lpthread  -lcrypt
libtool: link: i686-pc-linux-gnu-gcc -shared  .libs/couch_icu_driver_la-couch_icu_driver.o   -L/usr/lib -L/usr/lib/xulrunner-2.0 -L/usr/local/lib -L/opt/local/lib -lm -licuuc -licudata -licui18n -lpthread -lcrypt  -march=core2 -Wl,-O1 -Wl,--as-needed   -Wl,-soname -Wl,couch_icu_driver.so -o .libs/couch_icu_driver.so
mv -f .deps/couchjs-http.Tpo .deps/couchjs-http.Po
/bin/sh ../../../libtool --tag=CC   --mode=link i686-pc-linux-gnu-gcc -D_BSD_SOURCE  -O2 -march=core2 -pipe -g -lcurl -L/usr/lib/xulrunner-2.0 -L/usr/local/lib -L/opt/local/lib -I/usr/lib/erlang/usr/include -I/usr/include/xulrunner-2.0 -DXP_UNIX  -lm -Wl,-O1 -Wl,--as-needed -o couchjs couchjs-http.o couchjs-main.o couchjs-utf8.o -lcurl -lmozjs -L/usr/lib/xulrunner-2.0 -L/usr/local/lib -L/opt/local/lib -lpthread  -lcrypt
libtool: link: ( cd ".libs" && rm -f "couch_icu_driver.la" && ln -s "../couch_icu_driver.la" "couch_icu_driver.la" )
libtool: link: i686-pc-linux-gnu-gcc -D_BSD_SOURCE -O2 -march=core2 -pipe -g -I/usr/lib/erlang/usr/include -I/usr/include/xulrunner-2.0 -DXP_UNIX -Wl,-O1 -Wl,--as-needed -o couchjs couchjs-http.o couchjs-main.o couchjs-utf8.o  -L/usr/lib/xulrunner-2.0 -L/usr/local/lib -L/opt/local/lib -lm /usr/lib/libcurl.so -lmozjs -lpthread -lcrypt
couchjs-http.o: In function `status':
/var/tmp/portage/dev-db/couchdb-1.0.2-r1/work/apache-couchdb-1.0.2/src/couchdb/priv/couch_js/http.c:289: undefined reference to `INT_FITS_IN_JSVAL'
couchjs-main.o: In function `seal':
/var/tmp/portage/dev-db/couchdb-1.0.2-r1/work/apache-couchdb-1.0.2/src/couchdb/priv/couch_js/main.c:209: undefined reference to `JS_SealObject'
couchjs-main.o: In function `readfp':
/var/tmp/portage/dev-db/couchdb-1.0.2-r1/work/apache-couchdb-1.0.2/src/couchdb/priv/couch_js/main.c:134: undefined reference to `js_fgets'
couchjs-main.o: In function `evalcx':
/var/tmp/portage/dev-db/couchdb-1.0.2-r1/work/apache-couchdb-1.0.2/src/couchdb/priv/couch_js/main.c:62: undefined reference to `JS_GetStringChars'
couchjs-utf8.o: In function `enc_string':
/var/tmp/portage/dev-db/couchdb-1.0.2-r1/work/apache-couchdb-1.0.2/src/couchdb/priv/couch_js/utf8.c:132: undefined reference to `JS_GetStringChars'
collect2: ld returned 1 exit status
make[4]: *** [couchjs] Fehler 1
make[4]: Leaving directory `/var/tmp/portage/dev-db/couchdb-1.0.2-r1/work/apache-couchdb-1.0.2/src/couchdb/priv'
make[3]: *** [all-recursive] Fehler 1
make[3]: Leaving directory `/var/tmp/portage/dev-db/couchdb-1.0.2-r1/work/apache-couchdb-1.0.2/src/couchdb'
make[2]: *** [all-recursive] Fehler 1
make[2]: Leaving directory `/var/tmp/portage/dev-db/couchdb-1.0.2-r1/work/apache-couchdb-1.0.2/src'
make[1]: *** [all-recursive] Fehler 1
make[1]: Leaving directory `/var/tmp/portage/dev-db/couchdb-1.0.2-r1/work/apache-couchdb-1.0.2'
make: *** [all] Fehler 2
Comment 1 Tilo Prütz 2011-05-10 09:52:00 UTC
I forgot to mention, that I had seen bug 349660, bug 349824 and bug 349825 which seem similar.
Comment 2 Dirkjan Ochtman (RETIRED) gentoo-dev 2011-05-13 06:13:36 UTC
Mozilla team, any hints on how to select the correct libmozjs would be welcome.
Comment 3 Ian Stakenvicius (RETIRED) gentoo-dev 2011-05-16 15:30:11 UTC
This issue would relate specifically to -L paths; I have a similar (but different) issue with xulrunner-1.9 and above and the system-wide expat.  

-I  (and -L) override the default search path, ie, they are always used first.  So, since libmozjs.so is found in -L/usr/lib/xulrunner-2.0 it will never be grabbed from /usr/lib/.  The only way around this, afaik, is to position spidermonkey's libmozjs.so (or a simlink to it) in some other path, and then you can sort out the appropriate precedence to -L/path/to/spidermonkey/lib such that it is grabbed instead of xulrunner's.

I haven't looked at this package in particular, but would it be possible to exclude it from using xulrunner at all?  that would fix the issue too, more or less.  It might be possible to patch ./configure (and maybe the makefiles) to get things to work cleaner, too; especially if bug 361937 gets applied and spidermonkey's lib flags can be read via pkg-config.
Comment 4 Ian Stakenvicius (RETIRED) gentoo-dev 2011-06-17 21:29:40 UTC
...AND it seems that I have an issue that's the converse of this one.  When I compile a package that uses xulrunner-2 and spidermonkey-1.9 is not installed, it will grab libmozjs from xulrunner-2, but when i try and compile it when spidermonkey-1.9 *is* installed, then it grabs libmozjs from /usr/lib instead of from the -L path as specified via `pkg-config --libs mozilla-js`.

Does /usr/lib , etc (the defaults) take precedence over paths specified by -L ?  (googling didn't turn up an answer, although the gcc manpage seems to say that this is so, which means i was wrong in my previous comment)
Comment 5 Nirbheek Chauhan (RETIRED) gentoo-dev 2011-06-22 02:22:41 UTC
(In reply to comment #4)
> ...AND it seems that I have an issue that's the converse of this one.  When I
> compile a package that uses xulrunner-2 and spidermonkey-1.9 is not installed,
> it will grab libmozjs from xulrunner-2, but when i try and compile it when
> spidermonkey-1.9 *is* installed, then it grabs libmozjs from /usr/lib instead
> of from the -L path as specified via `pkg-config --libs mozilla-js`.
> 
> Does /usr/lib , etc (the defaults) take precedence over paths specified by -L ?
>  (googling didn't turn up an answer, although the gcc manpage seems to say that
> this is so, which means i was wrong in my previous comment)

It depends on the order of the libraries which are passed to libtool during linking. We faced the same problem with dev-libs/gjs, and had to resort to build-time blockers on spidermonkey.

This problem will go away once we add mozjs185[1], and when Firefox 5.0 goes stable, because xulrunner won't be needed, and mozjs185 has a pkgconfig file.

1. https://bugzilla.mozilla.org/show_bug.cgi?id=628723

PS: the spidermonkey version got downgraded to 1.8.2.x precisely for this reason, editing subject to reflect that
Comment 6 Ian Stakenvicius (RETIRED) gentoo-dev 2011-07-29 20:35:06 UTC
It should be noted that this package will not build against spidermonkey-1.8.5 as it does not check for libmozjs185.so but just libmozjs.so .. so the dep should be updated to reflect this, ie, "<dev-lang/spidermonkey-1.8.5" for both ebuilds.

Note that upstream does apparently have code (in configure.ac at least) to handle proper detection and usage of spidermonkey-1.8.5, so a version bump may be appropriate.

---

Back to the original issue, I am not understanding why this error occurs.  spidermonkey-1.8.2.* installs /usr/lib/libmozjs.so, and from what I can see in ./configure there is no reason why -L/usr/lib/xulrunner-* would be added to LDFLAGS and if that doesn't happen then this bug should never occur.

Other packages (gjs, freewrl) are having the opposite issue -- package is built against xulrunner and the spidermonkey causes it to crash out.  This package should not have this issue.

# ldd /usr/lib64/couchdb/bin/couchjs:
     libmozjs.so => /usr/lib64/libmozjs.so (0xHEXHEXHEXHEX)
Comment 7 Dirkjan Ochtman (RETIRED) gentoo-dev 2011-08-07 13:46:15 UTC
AFAIK dev-db/couchdb does not support spidermonkey-1.8.5 in any released versions, and it might not even support it in 1.1.1, when that comes out.
Comment 8 Tilo Prütz 2011-10-10 06:02:46 UTC
As mentioned in comment 5 the problem vanishes with spidermonkey 1.8.5 but one has to patch couchdb because it does not officially support spidermonkey 1.8.5 as mentioned in comment 7.

Please find attached the couchdb (1.1.0) patch I am using for spidermonkey 1.8.5.
Comment 9 Tilo Prütz 2011-10-10 06:03:46 UTC
Created attachment 289427 [details, diff]
couchdb 1.1.0 patch for spidermonkey 1.8.5
Comment 10 Dirkjan Ochtman (RETIRED) gentoo-dev 2011-10-31 14:34:08 UTC
I've just bumped couchdb to 1.1.1, which should work with spidermonkey-1.8.5. Does that leave any issues on the table here?
Comment 11 Ian Stakenvicius (RETIRED) gentoo-dev 2011-11-14 21:50:48 UTC
It would seem that, when 1.1.1 goes stable and/or xulrunner-2 is removed, then this bug would definitely be fixed.

I am still wondering, though, if the original issue (xulrunner-2 conflicting with spidermonkey-1.8.2.15) is actually repeatable, since xulrunner-2's libs and such are separate from the default lib paths and as such should not be found.  If my theory is correct then the whole bug should be close'able.
Comment 12 Ian Stakenvicius (RETIRED) gentoo-dev 2011-11-22 21:10:04 UTC
removing blocker to spidermonkey-1.8.5 unmasking, since couchdb-1.1.1 works with it.
Comment 13 Jory A. Pratt gentoo-dev 2012-02-12 14:29:29 UTC
I do not see anything needed by the mozilla team here, if you need us feel free to cc us back.
Comment 14 Samuli Suominen (RETIRED) gentoo-dev 2012-07-04 07:48:34 UTC
Let's summarize:

- net-libs/xulrunner was punted from tree wrt bug 403415
- couchdb-1.2.0 is in ~arch and works with ~arch spidermonkey 1.8.5

So nothing left to do here, right?

Closing