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

Public API of spirv-tools exposes UB to safe code #27

Closed
dtolnay opened this issue Sep 19, 2021 · 0 comments · Fixed by #28
Closed

Public API of spirv-tools exposes UB to safe code #27

dtolnay opened this issue Sep 19, 2021 · 0 comments · Fixed by #28
Labels
bug Something isn't working

Comments

@dtolnay
Copy link

dtolnay commented Sep 19, 2021

Describe the bug
For example, the following safe program leads to spirv-tools performing Undefined Behavior:

// [dependencies]
// spirv-tools = "0.7.0"

use std::convert::TryFrom;

fn main() {
    let _ = spirv_tools::error::Diagnostic::try_from(0xdeadbeefusize as *mut _);
}

To Reproduce
Put the code above into a src/main.rs, and the dependency on spirv-tools into a Cargo.toml and run using cargo run.

Segmentation fault (core dumped)

Expected behavior
In general it is unsound for a safe API to result in UB. An API that is liable to cause UB should not be callable from safe code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant