cuviper / autocfg

Automatic cfg for Rust compiler features
Apache License 2.0
95 stars 24 forks source link

Program unexpected panic when unwrap is used #52

Closed bhao-Soo closed 1 year ago

bhao-Soo commented 1 year ago

version of autocfg

the newest version.

Bug description

Program unwrap on an "Err" value, which causing a panic

Steps to reproduce the behavior

Using auto-generated fuzz target can reproduce the behavior. it was uploaded to the issue platform. unwrap_error.zip

actual behavior, and expected behavior.

actual: Panic happens, the program crashes. expected: Handle unwrap without causing a panic.

cuviper commented 1 year ago

Calling unwrap is not inherently a bug, especially when the function is documented to have panic conditions.

Your program calls autocfg::new(), which says, "Panics if AutoCfg::new() returns an error." That in turn documents several common errors, including "OUT_DIR is not set in the environment, or is not a writable directory." That's the panic I get when I run your code directly, but it's fine when I do set OUT_DIR -- and typically that will be set by cargo when autocfg is used in a build script.