Open matthiaskrgr opened 2 years ago
I think Miri is correct here. I'm pretty sure #[start]
runs before the Rust runtime is initialized, which means there is nothing to catch a panic. I can't tell if the feature is documented anywhere, the unstable book just links to tracking issue, which dates back to 2015: https://github.com/rust-lang/rust/issues/29633
But the opening comment does say
In general this forgoes a bit of runtime setup that's normally run before and after main.
Though it's hard to tell if that is normative or correct, being that is an unstable feature and that was 7 years ago.
This feature is incredibly poorly documented, and because of that, I think most people end up using platform-specific linker things to get the same result, which leads to less interest in the feature, which means there's less effort to document it, and it's a horrible cycle.
Libstd's lang_start
impl wraps all calls it does in catch_unwind
to avoid UB.
It is my understanding that a panic "leaving" the top of the Rust-controlled stack is UB, and that is the check that Miri is implementing here.
Maybe we should add this as a testcase. :D
I tried this code:
miri reports:
which does not happen when I just
panic!()
without a#[start]
fnmiri 0.1.0 (3b8b6aa 2022-05-06)