[quickjs-devel] Re: quickjs & threads

  • From: Koushik Dutta <koush@xxxxxxxxxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Thu, 23 Jan 2020 10:56:38 -0800

Your analysis is correct. I responded to your previous email as I also
encountered this issue.

On Thu, Jan 23, 2020 at 10:13 AM Fred Weigel <fred_weigel@xxxxxxxxxxx>
wrote:

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: