Feature/custom handler#29
Merged
Merged
Conversation
…r zkVM Wrap exit/_Exit/abort so musl's exit_group (syscall 94) is replaced by pal's real ZisK exit ecall (a7=93), which ZisK recognizes as program end. Also no-op RhpReversePInvoke/RhpReversePInvokeReturn, whose GC-safe-point parking deadlocks when a managed exception handler is entered from __wrap_RhpThrowEx in the single-threaded zkVM. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
musl's exit()/_Exit()/abort() issue exit_group (94), which ZisK does not recognise as program end, leaving emulation "not completed". Wrap these terminators via --wrap to emit the real ZisK exit ecall (a7 == 93, CAUSE_EXIT) so the emulator sees the `end` flag and stops cleanly. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
Add --wrap linker flags for exit, _Exit, and abort so these libc calls can be redirected to the ZisK exit ecall. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
No-op RhpReversePInvoke and RhpReversePInvokeReturn: in the zkVM the thread is already cooperative when a managed exception handler runs, so the real AttachOrTrapThread2 transition spins on a GC rendezvous that never comes. RhpThrowEx now forwards the managed exception object to a weakly-linked ZkvmThrow handler that programs may export via [UnmanagedCallersOnly]; absent that symbol it falls back to exit(1), so existing binaries are unchanged. FailFast keeps the plain fail-fast path since it carries a message, not an exception object. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
Add --wrap flags for RhpReversePInvoke and RhpReversePInvokeReturn so the zkVM linker can intercept these reverse P/Invoke transitions alongside the existing forward P/Invoke wrappers. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
Add a sample showing how to take over the zkVM fail-fast on a managed throw with a C# handler. The wrapped RhpThrowEx forwards the exception object to a weak ZkvmThrow symbol, which a program exports via UnmanagedCallersOnly to receive the live Exception, print it via sys_write, and exit through the native Zisk exit ecall. The README documents the throw routing and the two zkVM-specific rules: print with sys_write rather than Console, and terminate with native exit() rather than Environment.Exit to avoid recursing through the handler. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.