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-probe: use UDF instruction on nested panics #594

Merged
merged 1 commit into from
Sep 28, 2021
Merged

Conversation

japaric
Copy link
Member

@japaric japaric commented Sep 28, 2021

given this code:

use panic_probe as _;

struct S;

impl defmt::Format for S {
    fn format(&self, _: defmt::Formatter) {
        defmt::panic!()
    }
}

#[cortex_m_rt::entry]
fn main() -> ! {
    defmt::panic!("{}", S)
}

before this PR:

$ cargo rb panic
(HOST) INFO  flashing program (6.66 KiB)
(HOST) INFO  success!
────────────────────────────────────────────────────────────────────────────────
────────────────────────────────────────────────────────────────────────────────
(HOST) INFO  device halted without error

$ echo $?
0

after this PR:

(HOST) INFO  flashing program (6.64 KiB)
(HOST) INFO  success!
────────────────────────────────────────────────────────────────────────────────
────────────────────────────────────────────────────────────────────────────────
stack backtrace:
   0: HardFaultTrampoline
      <exception entry>
   1: lib::inline::__udf
        at ./asm/inline.rs:172:5
   2: __udf
        at ./asm/lib.rs:49:17
   3: cortex_m::asm::udf
        at /home/japaric/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/cortex-m-0.7.3/src/asm.rs:43:5
   4: rust_begin_unwind
        at /home/japaric/.cargo/git/checkouts/defmt-52fbd7917982cfac/76a0478/firmware/panic-probe/src/lib.rs:72:9
   5: core::panicking::panic_fmt
        at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:92:14
   6: core::panicking::panic
        at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:50:5
   7: <defmt_rtt::Logger as defmt::traits::Logger>::acquire
        at /home/japaric/.cargo/git/checkouts/defmt-52fbd7917982cfac/76a0478/firmware/defmt-rtt/src/lib.rs:45:13
(..)
(HOST) ERROR the program panicked

$ echo $?
6

@jonas-schievink
Copy link
Contributor

bors r+

@bors
Copy link
Contributor

bors bot commented Sep 28, 2021

Build succeeded:

@bors bors bot merged commit 7cef8eb into main Sep 28, 2021
@bors bors bot deleted the udf-on-nested-panic branch September 28, 2021 14:16
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

Successfully merging this pull request may close these issues.

None yet

2 participants