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

println!() can cause panic outside catch_unwind() #118

Open
LegionMammal978 opened this issue Jul 9, 2022 · 1 comment
Open

println!() can cause panic outside catch_unwind() #118

LegionMammal978 opened this issue Jul 9, 2022 · 1 comment
Labels

Comments

@LegionMammal978
Copy link

LegionMammal978 commented Jul 9, 2022

The miniz_oxide_c_api wrappers in src/lib.rs call println!("FATAL ERROR: Caught panic!"); when a panic is caught. println!() can panic if it fails to write, causing UB if panic = "abort" is not set. Replacing it with let _ = write!(io::stdout(), "FATAL ERROR: Caught panic!"); would make it ignore any write errors.

(As a side note, I tried to find any code paths that actually cause a panic, but could not find any. Is miniz_oxide designed to never panic in the absence of bugs?)

@oyvindln
Copy link
Collaborator

oyvindln commented Jul 9, 2022

Ah, should look at finding some other way to handle that then

And yeah miniz isn't designed to explicitly panic anywhere (though it's plausible that improper use of the unsafe c api bits could cause out of bounds panics or similar.)

@oyvindln oyvindln added the C API label Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants