Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the actual stacktrace how we end up here in cooperative mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's JS
setTimeout()-> C# threadpool -> xunit last item -> Environment.Exit -> posix exit() -> emscripten thread destructorCopilot thinks:
ExecuteInterpretedMethodFromUnmanaged(pMD, …)— prestub.cpp. These are the per-method reverse thunks generated in wasm/browser/callhelpers-reverse.cpp, e.g.CallEntryPoint(managedMain),CallJSExport,CallDelegate,CompleteTask(JS interop), class-ctor/default-ctor helpers, etc.ExecuteInterpretedMethodWithArgs— prestub.cppExecuteInterpretedMethod— prestub.cpp, which first asserts the caller is preemptive (if (thread->PreemptiveGCDisabled()) ReversePInvokeBadTransition();), then does theGCX_MAYBE_COOPtransition above.InterpExecMethodruns the bytecode inMODE_COOPERATIVE(interpexec.cpp), toggling back to preemptive withGCX_PREEMP_NO_DTOR()only for outbound unmanaged/P-Invoke calls (interpexec.cpp).I will try to catch the real native stack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one I can easily reproduce, but it's not the one which asserts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I would expect C runtime
exitto be always called in preemptive mode. I think the problem should be fixed closer to where we are calling C runtimeexitin cooperative mode.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is broken call with R2R into UCO which causes subsequent posix
exit()but the GC mode is off-balance already.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can
InvokeCalliStub -> CallFunc_This_RetI32_PEcatch that JS exception/trap ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be fatal error that makes us abort immediately.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a way, this is abort. It's on emscripten/js level. Perhaps abort needs to uninstall __funcs_on_exit callbacks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#130613