mozilla / spidernode

Node.js on top of SpiderMonkey
https://ehsanakhgari.org/blog/2016-04-20/project-spidernode
Other
561 stars 42 forks source link

builds against external SpiderMonkey with NSPR/NSS on Linux crash #206

Open mykmelez opened 8 years ago

mykmelez commented 8 years ago

After #205, building SpiderNode against an external SpiderMonkey with NSPR/NSS on Linux succeeds, but the build crashes when JS::detail::InitWithFailureDiagnostic calls mozilla::TimeStamp::ProcessCreation (which should be provided by mozglue):

Starting program: /home/myk/Projects/spidernode/node_g 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff7ff7700 (LWP 95706)]

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x0000000000839be7 in JS::detail::InitWithFailureDiagnostic (isDebugBuild=true) at /home/myk/Projects/gecko-dev/js/src/vm/Initialization.cpp:87
#2  0x00000000007ab85d in JS_Init () at /home/myk/Projects/spidernode/out/Debug/spidermonkey/Debug/dist/include/js/Initialization.h:68
#3  0x00000000007ab501 in v8::V8::Initialize () at ../deps/spidershim/src/v8v8.cc:39
#4  0x00000000006df693 in node::Start (argc=1, argv=0x2b8c9a0) at ../src/node.cc:4509
#5  0x0000000000713fa7 in main (argc=1, argv=0x7fffffffdfc8) at ../src/node_main.cc:58

The failure does not occur when building against an external SpiderMonkey that doesn't have NSPR/NSS, f.e. in automation. It also doesn't occur with NSPR/NSS on Mac. Nor builds against internal SpiderMonkey. It's specific to external SpiderMonkey with NSPR/NSS on Linux.

ehsan commented 8 years ago

Does this go away if you applied https://github.com/mozilla/spidernode/blob/master/deps/spidershim/spidermonkey-patches/01-mozglue-linux-fix.patch to your external SpiderMonkey tree and rebuild?

mykmelez commented 8 years ago

Does this go away if you applied https://github.com/mozilla/spidernode/blob/master/deps/spidershim/spidermonkey-patches/01-mozglue-linux-fix.patch to your external SpiderMonkey tree and rebuild?

I already have that patch applied (as well as the other patch in that directory), and I'm building the same branch on both Mac (where it works) and Linux (where it crashes). This is the branch I'm using to build external SpiderMonkey:

https://github.com/mykmelez/gecko-dev/tree/support-spidernode

The repository is a fork of gecko-dev, but the branch itself is using cinnabar. It's merged with the same upstream commit as SpiderNode (e287e69). Here's the relevant part of js/src/old-configure.in, which is identical to the same section of code in SpiderNode's internal SpiderMonkey:

dnl In stand-alone builds we always only want to link executables against mozglue.
if test "$JS_STANDALONE"; then
  MOZ_GLUE_IN_PROGRAM=
else
  case "${OS_TARGET}" in
  Android|WINNT|Darwin)
    MOZ_GLUE_IN_PROGRAM=
    ;;
  *)
    dnl On !Android !Windows !OSX, we only want to link executables against mozglue
    MOZ_GLUE_IN_PROGRAM=1
    AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
    ;;
  esac
fi

And here's the complete comparison between the branch and the upstream revision:

https://github.com/mykmelez/gecko-dev/compare/e287e69...support-spidernode

ehsan commented 8 years ago

Hmm. The symptoms of what you're describing (crashing when you first call into mozglue only on Linux). It's totally possible that the fix in the patch mentioned above is insufficient to fix this symptom, but this is way out of my comfort zone. Perhaps @glandium may be able to help?