On Wednesday, March 30, 2016 at 6:24:38 PM UTC+2, Jason Orendorff wrote:
> Buiding SpiderMonkey creates a header, dist/include/js-config.h, that
> defines all these. It is included from jsapi.h (-> jspubtd.h -> jstypes.h
> -> js-config.h). I think the easiest way to mess it up is not by failing to
> -DDEBUG, but by compiling correctly --- and then linking against the wrong
> SM shared library.
I am sure I am using the correct library, the path is everywhere: in the assertion message, in the backtrace, ... And the offsetof warning tell me which header are included.
I rewrote a simple program:
#include <cstdlib>
#include <cstdio>
#include <jsapi.h>
extern "C" {
#include <pthread.h>
}
constexpr uint32_t RT_MAX_BYTES = 8ul*1024ul*1024ul;
JSRuntime *main_rt;
void *worker (void *arg)
{
JSRuntime *rt = JS_NewRuntime (RT_MAX_BYTES, JS::DefaultNurseryBytes, main_rt);
if (!rt)
fprintf (stderr, "JS_NewRuntime failed");
printf ("in worker\n");
JS_DestroyRuntime (rt);
}
int main ()
{
int ret;
if (!JS_Init ()) {
fprintf (stderr, "JS_Init failed\n");
return EXIT_FAILURE;
}
main_rt = JS_NewRuntime (RT_MAX_BYTES);
if (!main_rt)
fprintf (stderr, "JS_NewRuntime failed");
pthread_t thread;
if (0 != (ret = pthread_create (&thread, nullptr, worker, nullptr))) {
fprintf (stderr, "pthread_create failed: %s\n", strerror (ret));
}
pthread_join (thread, nullptr);
JS_DestroyRuntime (main_rt);
JS_ShutDown ();
return EXIT_SUCCESS;
}
This should work, right?
Assertion failure: !isLocked(), at /home/clement/src/mozilla-esr38/js/src/vm/HelperThreads.cpp:515
(gdb) bt
#0 0x00007ffff67abd12 in js::GlobalHelperThreadState::lock (this=0x614ca0) at /home/clement/src/mozilla-esr38/js/src/vm/HelperThreads.cpp:515
#1 0x00007ffff667a422 in js::AutoLockHelperThreadState::AutoLockHelperThreadState (this=0x7ffff4f09dbf, _notifier=...) at /home/clement/src/mozilla-esr38/js/src/vm/HelperThreads.h:415
#2 0x00007ffff67ab78a in js::GlobalHelperThreadState::ensureInitialized (this=0x614ca0) at /home/clement/src/mozilla-esr38/js/src/vm/HelperThreads.cpp:446
#3 0x00007ffff67a9f5a in js::EnsureHelperThreadsInitialized () at /home/clement/src/mozilla-esr38/js/src/vm/HelperThreads.cpp:58
#4 0x00007ffff6862fc4 in JSRuntime::init (this=0x7fffc80008c0, maxbytes=8388608, maxNurseryBytes=16777216) at /home/clement/src/mozilla-esr38/js/src/vm/Runtime.cpp:268
#5 0x00007ffff6cdccaa in JS_NewRuntime (maxbytes=8388608, maxNurseryBytes=16777216, parentRuntime=0x615020) at /home/clement/src/mozilla-esr38/js/src/jsapi.cpp:472
#6 0x0000000000400a5b in worker (arg=0x0) at main.cpp:13
#7 0x00007ffff620d60a in start_thread () from /lib64/libpthread.so.0
#8 0x00007ffff56aca4d in clone () from /lib64/libc.so.6
(gdb) info threads
Id Target Id Frame
* 10 Thread 0x7ffff4f0a700 (LWP 18925) "a.out" 0x00007ffff67abd12 in js::GlobalHelperThreadState::lock (this=0x614ca0) at /home/clement/src/mozilla-esr38/js/src/vm/HelperThreads.cpp:515
9 Thread 0x7ffff4f8b700 (LWP 18924) "Analysis Helper" 0x00007ffff6212b10 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
8 Thread 0x7ffff500c700 (LWP 18923) "Analysis Helper" 0x00007ffff6212b10 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
7 Thread 0x7ffff508d700 (LWP 18922) "Analysis Helper" 0x00007ffff6212b10 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
6 Thread 0x7ffff510e700 (LWP 18921) "Analysis Helper" 0x00007ffff6212b10 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
5 Thread 0x7ffff518f700 (LWP 18920) "Analysis Helper" 0x00007ffff6212b10 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
4 Thread 0x7ffff7ec6700 (LWP 18919) "Analysis Helper" 0x00007ffff6212b10 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
3 Thread 0x7ffff7f47700 (LWP 18918) "Analysis Helper" 0x00007ffff6212b10 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
2 Thread 0x7ffff7fc8700 (LWP 18917) "Analysis Helper" 0x00007ffff6212b10 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
1 Thread 0x7ffff7fca740 (LWP 18912) "a.out" 0x00007ffff620e6ad in pthread_join () from /lib64/libpthread.so.0
Compiled with:
g++ -g -std=c++11 main.cpp -include /home/clement/opt/mozjs-38.hg-debug/include/mozjs-38/js/RequiredDefines.h -I/home/clement/opt/mozjs-38.hg-debug/include/mozjs-38 -I/usr/include/nspr4 -L/home/clement/opt/mozjs-38.hg-debug/lib -lmozjs-38 -lpthread
and LD_LIBRARY_PATH=/home/clement/opt/mozjs-38.hg-debug/lib/
I don't know enough about SM internals to know the relevant places to test that but when the assertion fails lockOwner is null. PR_GetCurrentThread () also returns 0.
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.