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

Soundness issues in autogenerated code #26

Open
alice-i-cecile opened this issue Jun 5, 2022 · 0 comments
Open

Soundness issues in autogenerated code #26

alice-i-cecile opened this issue Jun 5, 2022 · 0 comments

Comments

@alice-i-cecile
Copy link

alice-i-cecile commented Jun 5, 2022

The following snippet extracted from this crate failed under MIRI:

fn main() {
    unsafe {
        let mut piHashTable = vec![0i32; 10];
        
        let mut pTable = &mut piHashTable[2] as *mut i32;
        *pTable.offset(3) = 2 as i32;
    } 
}

error: Undefined Behavior: attempting a write access using <3294> at alloc1703[0x14], but that tag does not exist in the borrow stack for this location
--> src/main.rs:6:9
|
6 | *pTable.offset(3) = 2 as i32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| attempting a write access using <3294> at alloc1703[0x14], but that tag does not exist in the borrow stack for this location
| this error occurs as part of an access at alloc1703[0x14..0x18]
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <3294> was created by a retag at offsets [0x8..0xc]
--> src/main.rs:5:26
|
5 | let mut pTable = &mut piHashTable[2] as *mut i32;
| ^^^^^^^^^^^^^^^^^^^
= note: inside main at src/main.rs:6:9

This was noticed as part of bevyengine/bevy#4932, an effort to rewrite this crate into idiomatic Rust. There may be other soundness issues; the autogenerated code uses a lot of pointless unsafe in strange ways.

bors bot pushed a commit to bevyengine/bevy that referenced this issue Jul 16, 2022
# Objective

- 0.8 is coming soon, and our mikktspace implementation is unsound - see gltf-rs/mikktspace#26
- Best not to ship that

## Solution

- Fix the unsoundness in a minimal way
- Obviously there might be others, but it seems unlikely we have any way to know about those
bors bot pushed a commit to bevyengine/bevy that referenced this issue Jul 16, 2022
# Objective

- 0.8 is coming soon, and our mikktspace implementation is unsound - see gltf-rs/mikktspace#26
- Best not to ship that

## Solution

- Fix the unsoundness in a minimal way
- Obviously there might be others, but it seems unlikely we have any way to know about those
bors bot pushed a commit to bevyengine/bevy that referenced this issue Jul 16, 2022
# Objective

- 0.8 is coming soon, and our mikktspace implementation is unsound - see gltf-rs/mikktspace#26
- Best not to ship that

## Solution

- Fix the unsoundness in a minimal way
- Obviously there might be others, but it seems unlikely we have any way to know about those
inodentry pushed a commit to IyesGames/bevy that referenced this issue Aug 8, 2022
# Objective

- 0.8 is coming soon, and our mikktspace implementation is unsound - see gltf-rs/mikktspace#26
- Best not to ship that

## Solution

- Fix the unsoundness in a minimal way
- Obviously there might be others, but it seems unlikely we have any way to know about those
james7132 pushed a commit to james7132/bevy that referenced this issue Oct 28, 2022
# Objective

- 0.8 is coming soon, and our mikktspace implementation is unsound - see gltf-rs/mikktspace#26
- Best not to ship that

## Solution

- Fix the unsoundness in a minimal way
- Obviously there might be others, but it seems unlikely we have any way to know about those
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

- 0.8 is coming soon, and our mikktspace implementation is unsound - see gltf-rs/mikktspace#26
- Best not to ship that

## Solution

- Fix the unsoundness in a minimal way
- Obviously there might be others, but it seems unlikely we have any way to know about those
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant