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

Panic handler causes infinite panic recursion #87

Open
ttencate opened this issue Feb 23, 2024 · 0 comments
Open

Panic handler causes infinite panic recursion #87

ttencate opened this issue Feb 23, 2024 · 0 comments

Comments

@ttencate
Copy link
Contributor

#0  0x00007d697410dae4 in core::any::{impl#4}::is<&str> (self=..., self=...)
    at /rustc/98aa3624be70462d6a25ed5544333e3df62f4c66/library/core/src/any.rs:200
#1  core::any::{impl#4}::downcast_ref<&str> (self=...)
    at /rustc/98aa3624be70462d6a25ed5544333e3df62f4c66/library/core/src/any.rs:228
#2  core::any::{impl#5}::downcast_ref<&str> (self=...)
    at /rustc/98aa3624be70462d6a25ed5544333e3df62f4c66/library/core/src/any.rs:379
#3  crankstart::panic (panic_info=<optimized out>) at src/lib.rs:297
#4  0x00007d69740ff796 in core::panicking::panic_nounwind_fmt::runtime () at library/core/src/panicking.rs:110
#5  core::panicking::panic_nounwind_fmt () at library/core/src/panicking.rs:122
#6  0x00007d69740ff88a in core::panicking::panic_misaligned_pointer_dereference ()
    at library/core/src/panicking.rs:221
#7  0x00007d697410dc13 in crankstart::abort_with_addr (addr=137891872414744) at src/lib.rs:286
#8  0x00007d697410dbde in crankstart::panic (panic_info=<optimized out>) at src/lib.rs:323
#9  0x00007d69740ff796 in core::panicking::panic_nounwind_fmt::runtime () at library/core/src/panicking.rs:110
#10 core::panicking::panic_nounwind_fmt () at library/core/src/panicking.rs:122
#11 0x00007d69740ff88a in core::panicking::panic_misaligned_pointer_dereference ()
    at library/core/src/panicking.rs:221
#12 0x00007d697410dc13 in crankstart::abort_with_addr (addr=137891872414744) at src/lib.rs:286
#13 0x00007d697410dbde in crankstart::panic (panic_info=<optimized out>) at src/lib.rs:323
#14 0x00007d69740ff796 in core::panicking::panic_nounwind_fmt::runtime () at library/core/src/panicking.rs:110
#15 core::panicking::panic_nounwind_fmt () at library/core/src/panicking.rs:122
#16 0x00007d69740ff88a in core::panicking::panic_misaligned_pointer_dereference ()
    at library/core/src/panicking.rs:221

... and so on, ad infinitum or until the stack overflows with a segmentation fault.

The root cause is abort_with_addr trying to write to a misaligned pointer, 0xdeadbeef.

This can easily be fixed by changing the pointer to *mut u8, because this has size 1, which is guaranteed to be a multiple of the alignment which must therefore also be 1.

(Aside: It would also be nice if the abort could be suppressed with some kind of build flag, because it aborts the simulator before it has a chance to print the panic message.)

ttencate added a commit to ttencate/crankstart that referenced this issue Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant