Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trap when trying to raise wasm32 exceptions #12572

Merged
merged 2 commits into from
Oct 23, 2022

Conversation

lbguilherme
Copy link
Contributor

We don't support WASM exceptions yet. But in the mean time, let's at least get an usable stack trace there! It's a small quality of life improvement.

Before:

$ wasmtime run benchmark_spec 
EXITING: Attempting to raise:
Not Implemented: Crystal::EventLoop.create_resume_event (NotImplementedError)

After:

$ wasmtime run benchmark_spec 
EXITING: Attempting to raise:
Not Implemented: Crystal::EventLoop.create_resume_event (NotImplementedError)
Error: failed to run main module `benchmark_spec`

Caused by:
    0: failed to invoke command default
    1: wasm trap: wasm `unreachable` instruction executed
       wasm backtrace:
           0: 0x18c68 - <unknown>!*raise<NotImplementedError>:NoReturn
           1: 0xfcf06 - <unknown>!*Crystal::EventLoop::create_resume_event<Fiber>:NoReturn
           2: 0x7ae95 - <unknown>!*Fiber#resume_event:Crystal::Event
           3: 0xfe2aa - <unknown>!*Crystal::Scheduler#sleep<Time::Span>:Nil
           4: 0xfe259 - <unknown>!*Crystal::Scheduler::sleep<Time::Span>:Nil
           5: 0x1a776 - <unknown>!*sleep<Float64>:Nil
           6: 0x1a654 - <unknown>!~procProc(Nil)@spec/std/benchmark_spec.cr:16
           7: 0x159bc7 - <unknown>!*Benchmark::IPS::Entry#call:Nil
           8: 0x156d0c - <unknown>!*Benchmark::IPS::Job#run_warmup:Nil
           9: 0x156a77 - <unknown>!*Benchmark::IPS::Job#execute:Nil
          10: 0x1a3bc - <unknown>!~procProc(Nil)@spec/std/benchmark_spec.cr:12
          11: 0x123110 - <unknown>!*Spec::Example#internal_run<Time::Span, Proc(Nil)>:(Array(Spec::Result) | Nil)
          12: 0x122f49 - <unknown>!*Spec::Example#run:Nil
          13: 0x121a67 - <unknown>!*Spec::ExampleGroup@Spec::Context#internal_run:Nil
          14: 0x12170d - <unknown>!*Spec::ExampleGroup#run:Nil
          15: 0x10fe69 - <unknown>!*Spec::RootContext@Spec::Context#internal_run:Nil
          16: 0x10fd44 - <unknown>!*Spec::RootContext#run:Nil
          17: 0x18f0d - <unknown>!~procProc(Int32, (Exception | Nil), Nil)@src/spec/dsl.cr:216
          18: 0xfe7cb - <unknown>!*Crystal::AtExitHandlers::run<Int32, (Exception+ | Nil)>:Int32
          19: 0x1690fb - <unknown>!*Crystal::exit<Int32, (Exception+ | Nil)>:Int32
          20: 0x16909c - <unknown>!*Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32
          21: 0x17ca9 - <unknown>!main
          22: 0x17d2b - <unknown>!main
          23: 0x16c6ef - <unknown>!__main_void
          24: 0x17cda - <unknown>!_start
       note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable to may show more debugging information

Note that it is not possible to catch or recover from this trap.

@straight-shoota straight-shoota added this to the 1.7.0 milestone Oct 7, 2022
@straight-shoota straight-shoota merged commit 7fbf2f6 into crystal-lang:master Oct 23, 2022
lbguilherme added a commit to lbguilherme/crystal that referenced this pull request Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants