Listing lines that can panic in your crate #315
Replies: 15 comments
-
Whoops, this crate is about unsafe, not panics. |
Beta Was this translation helpful? Give feedback.
-
Interesting idea though! And, it's extra important to be panic/exception safe inside unsafe blocks, right? Finding potential panic sites inside unsafe blocks would be valuable. |
Beta Was this translation helpful? Give feedback.
-
@anderejd Please reopen this as a request for counting panics (and perhaps listing their lines). Panics are very overused in libraries, and can unexpectedly crash unwary users and poison their mutexes. |
Beta Was this translation helpful? Give feedback.
-
@alexchandel Afaik, |
Beta Was this translation helpful? Give feedback.
-
@alexchandel RazorFalcon is correct, this tools is not capable if that kind of analysis, at least not without a major rewrite. Maybe you would be interested in this: https://crates.io/crates/no-panic ? |
Beta Was this translation helpful? Give feedback.
-
Yes, but sometimes "no-panic" isn't achievable. What's needed is an analysis of panicking routes, for minimization. It might not be feasible now, but given the nature of panicking, it fits the idea of a "geiger counter." Slicing might show up a lot (absent a flag to ignore slicing panics), but often the compiler can prove a slice will never panic. |
Beta Was this translation helpful? Give feedback.
-
This sounds like it needs a call graph analyzer ala https://github.com/trailofbits/siderophile |
Beta Was this translation helpful? Give feedback.
-
Oh perhaps. I'll open it there. |
Beta Was this translation helpful? Give feedback.
-
https://github.com/Technolution/rustig already addresses this |
Beta Was this translation helpful? Give feedback.
-
@Shnatsel Does it actually works? Looks like it is abandoned and last time I've checked it didn't do anything. |
Beta Was this translation helpful? Give feedback.
-
I haven't tried it in a while, so can't really comment. |
Beta Was this translation helpful? Give feedback.
-
It seems this discussion is coming to life again, let's re-open the issue to make it more visible. |
Beta Was this translation helpful? Give feedback.
-
Well I went down a rabbithole today related to panic caused by the usual library-unwrap() and Err() pattern that had affected us and some others e.g. tarpaulin. I have a "want" to track down this pattern across ecosystem in weighted manner (I already have a synced & tracked copy of it) to trace that kind of pattern across libs to create analysis from weakest points in the ecosystem related to the pattern - binaries can panic all they want. I'll close this issue so it doesn't confuse from repo issues - if we find a security related use we could add issue in rust-secure-code/wg Perhaps we can moderate a moonshots tracker idea issue somewhere and refer from there to here so it's neither buried under a lot of other stuff e.g. repo issues. |
Beta Was this translation helpful? Give feedback.
-
Without suggesting reopening this ticket, I note that some use-cases for this may be served by the many Clippy lints returned by searching the Clippy lint index for "panic", with |
Beta Was this translation helpful? Give feedback.
-
Since clippy has introduced very geiger relevant #247 and we are thinking of introducing clippy runner as part of 0.12 this may be viable as a feature to plug into I'll convert this into discussion re: feasibility discussion |
Beta Was this translation helpful? Give feedback.
-
Is it possible? Something like this:
Beta Was this translation helpful? Give feedback.
All reactions