Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problems using JS in multithreaded environment

4 views
Skip to first unread message

Colin Blake

unread,
Sep 8, 2006, 9:07:46 PM9/8/06
to
We have some javascript code (in our mozilla based product) which
listens on a socket and creates threads (nsIThread) for each new
connection. The js code which runs in the threads' run() method does
some xpcom stuff and has been working reliably until recently. Problems
started when we pulled MOZILLA_1_8_BRANCH code around July 4th and we're
still having problems with current MOZILLA_1_8_BRANCH code. Problems
vary from ACCVIO's which look like random corruption, to hangs.

We're staying away from the DOM on the non-main threads, but what else
should we be avoiding? One thing our js code does do is to call
nsIThread::sleep(). Could this be causing synchronization problems? Or
if not all XPCOM interfaces are threadsafe, how can I easily determine
which ones are not?

Colin Blake

unread,
Sep 12, 2006, 12:08:39 PM9/12/06
to
Well, even without using sleep we seem to be having problems. In fact,
with the newly created thread doing nothing but returning, we still get
hangs.

Mike Moening

unread,
Sep 12, 2006, 2:42:19 PM9/12/06
to
There have been a lot of fixes in JS 1.7 since july.

There were a pile of threading issues with JS 1.7 that I ran into myself.
Crashes, dangling pointers, hangs, you name it.
Most were covered by the following bugs:

https://bugzilla.mozilla.org/show_bug.cgi?id=345350 (crash in
js_FreeRuntimeScriptState - jsscript.c)
https://bugzilla.mozilla.org/show_bug.cgi?id=345365 (JS_ClearContextThread
leaves dangling pointers in JSContext)
https://bugzilla.mozilla.org/show_bug.cgi?id=351602 (crash when GCThing
exists in both rt and thread local freeLists)

etc...

The patch for bug 351602 will probably be checked in today.
After getting this patch re-compile js and try again.

If you are on windows make sure you also define JS_USE_ONLY_NSPR_LOCKS in
your js builds.
That solved a lock hang problem for me.


Colin Blake

unread,
Sep 12, 2006, 8:09:36 PM9/12/06
to
Mike Moening wrote:

>If you are on windows make sure you also define JS_USE_ONLY_NSPR_LOCKS in
>your js builds.
>That solved a lock hang problem for me.
>
>

That has solved our hang problem. Why isn't this the default for Windows?

bre...@mozilla.org

unread,
Sep 29, 2006, 2:42:07 PM9/29/06
to
Colin Blake wrote:

Because it was slower, when last performance-tested. That was years
ago, so it could be that we should switch -- but first, I'd like to
find the source of the hang you and Mike saw.

Mike, could you send me fresh trace data?

/be

0 new messages