# \`setback\`: no\_std\` \`setjmp\`/\`longjmp\`-based fault recovery

**URL:** <https://users.rust-lang.org/t/setback-no-std-setjmp-longjmp-based-fault-recovery/140942>\
**Category:** code review\
**Created:** [June 25, 2026, 2:02pm UTC](https://users.rust-lang.org/t/setback-no-std-setjmp-longjmp-based-fault-recovery/140942 "2026-06-25T14:02:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ddystopia](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/ddystopia/32/34903_2.png) [@Ddystopia](https://users.rust-lang.org/u/Ddystopia)\
**Post date:** [June 25, 2026, 2:02pm UTC](https://users.rust-lang.org/t/setback-no-std-setjmp-longjmp-based-fault-recovery/140942/1 "2026-06-25T14:02:02Z")

</div>

Hello, I am working on embedded firmware that uses `minicbor`, `serde`, `wasmi`. Those crates are relatively pure, don't access global storage, are not `async` etc. But it is kind of hard to support, because there isn't that much RAM and you don't want to give too much unused stack to threads, but you have to give them enough - so the gap is not big. When something changes, I usually have to spend some time to hunt for stack overflows and rebalance stacks. It is a miracle it didn't overflowed some stack in deployment 😳 . As for `wasmi`, it is the only thing that uses allocator in the whole application (everything else is written from scratch and is stored in `StaticCell`, making linker the to be our allocator), so when it OOMs I can just never call into wasm again and never retag any references it may have, and report an error instead of resetting the device.

I had an idea and implemented it. Using a `longjump` to recover. I created a crate for this, what do you think? It is probably a formal UB to jump over Rust stack frames, but if you're careful I believe it can be used.

> **[GitHub - Ddystopia/setback: \`no\_std\` \`setjmp\`/\`longjmp\`-based failure recovery](https://github.com/Ddystopia/setback)**
>
> \`no\_std\` \`setjmp\`/\`longjmp\`-based failure recovery

---

<div class="post-metadata">

**Author:** ![kpreid](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/kpreid/32/22420_2.png) [@kpreid](https://users.rust-lang.org/u/kpreid)\
**Post date:** [June 25, 2026, 3:39pm UTC](https://users.rust-lang.org/t/setback-no-std-setjmp-longjmp-based-fault-recovery/140942/2 "2026-06-25T15:39:17Z")

</div>

> [@Ddystopia](#):
>
> It is probably a formal UB to jump over Rust stack frames, but if you're careful I believe it can be used.

[#t-opsem \> ✔ Still impossible to `longjmp` over Rust frames w/o UB?](https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/.E2.9C.94.20Still.20impossible.20to.20.60longjmp.60.20over.20Rust.20frames.20w.2Fo.20UB.3F/with/606522222)

---

<div class="post-metadata">

**Author:** ![Ddystopia](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/ddystopia/32/34903_2.png) [@Ddystopia](https://users.rust-lang.org/u/Ddystopia)\
**Post date:** [June 25, 2026, 8:20pm UTC](https://users.rust-lang.org/t/setback-no-std-setjmp-longjmp-based-fault-recovery/140942/3 "2026-06-25T20:20:34Z")

</div>

Yeah, thanks. Looking through it, I don't see any blockers for this crate 🤔

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/system/32/51372_2.png) [@system](https://users.rust-lang.org/u/system)\
**Post date:** [September 23, 2026, 8:21pm UTC](https://users.rust-lang.org/t/setback-no-std-setjmp-longjmp-based-fault-recovery/140942/4 "2026-09-23T20:21:06Z")

</div>

Closed on September 23, 2026, 8:21pm UTC

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.
