[quickjs-devel] Re: quickjs & threads

  • From: Fred Weigel <fred_weigel@xxxxxxxxxxx>
  • To: "quickjs-devel@xxxxxxxxxxxxx" <quickjs-devel@xxxxxxxxxxxxx>
  • Date: Thu, 23 Jan 2020 18:13:43 +0000

Ok

The exception is most likely coming from js_check_stack_overflow().

The two threads do NOT share the stack (separate stacks), so

size = ctx->stack_top - js_get_stack_pointer()

is likely giving an incorrect result.

To get this to work, consider using the EMSCRIPTEN definiitions of
js_get_stack_pointer() and js_check_stack_overflow (at line 1976 of
quickjs.c).

You can create a new context for the second thread -- this can share
objects with the first thread and its context (I haven't tried this
personally). This is probably tricky, but using the "no-operation"
versions of the stack-check function is also very hacky.

Please note that this entire analysis is pretty much a wild-assed
guess.

Fred Weigel

Other related posts: