Granular Unwind with asyncify_start_unwind(), getting unreachable

112 views
Skip to first unread message

Hostile Fork

unread,
Jun 26, 2022, 6:07:27 AM6/26/22
to emscripten-discuss
Hello!  I'm looking into unwinding to stack levels other than "the very top", which is all that emscripten_sleep() and friends seem to allow.

I found the following GitHub issue with an implementation of coroutines useful, for how to link and use the unwind/rewind functions:


From that I was able to build and use the browser's debugger to step into asyncify_start_unwind() all right.  It validates the stack_range I pass it, dodging an unreachable inside the call.  But right after it returns, there's an unreachable that fires:

     call $asyncify_start_unwind
     global.get $global3
     local.get $var4
     i32.ne
     if
         unreachable  ;; <- this is where the problem is
     end

$global3 is 1, set by asyncify_start_unwind().  And $var4 is 0.

This seems suspiciously to me as being like the Asyncify.state check which is done by emscripten to make sure that "unauthorized" functions don't change the unwinding state.  (I was pretty sure it wasn't some alias of Asyncify.state, but for the heck of it I tried setting that to unwinding to see if it made any difference.)

Is this some other variable with bookkeeping in a similar spirit?  It didn't seem the GitHub issue I referenced had to worry about this.  Is there a way of getting past this, to have that same level of coroutine control, while still using the higher-level Emscripten toolchain features and building for the web?

Thanks!
--Brian

P. S. I'm supposed to have maximum -g3 debug information on, but there's no way to trace to what $global3 or $var4 are supposed to mean.  Is there a view that would give a better hint?
Reply all
Reply to author
Forward
0 new messages