-
Notifications
You must be signed in to change notification settings - Fork 1
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
Miri failure on rustc 1.73.0-nightly (31395ec38 2023-07-24) #235
Labels
A-interner
Area: String interners, data structures, and types.
A-security
Area: Security vulnerabilities and unsoundness issues.
C-bug
Category: This is a bug.
E-help-wanted
Call for participation: Help is requested to fix this issue.
Comments
lopopolo
added
A-security
Area: Security vulnerabilities and unsoundness issues.
C-bug
Category: This is a bug.
labels
Jul 26, 2023
Implicated code: Lines 687 to 717 in 70ccd8b
|
lopopolo
added
E-help-wanted
Call for participation: Help is requested to fix this issue.
A-interner
Area: String interners, data structures, and types.
labels
Jul 26, 2023
lopopolo
added a commit
that referenced
this issue
Jul 26, 2023
This stacked borrows violation impacts all `SymbolTable` variants in this crate and has been present in all published versions. The `SymbolTable::intern` function previously worked like this: 1. Convert the given contents to be interned into a `Cow<'static, T>`. 2. Check to see if this content is already interned by checking the internal bimap. If found, return the matching symbol. 3. Convert the `Cow` into an `Interned` which is an enum of either a &'static T` or a `Box<T>`. 4. Borrow a `&'static T` from the `Interned`. 5. Push the `Interned` into the vec. 6. Add the `&'static T` to the map. 7. Check that the insertion happened correctly with some debug assertions. 8. Return the computed symbol. As of at least rustc 1.73.0-nightly (31395ec38 2023-07-24), Miri pops all borrows from the `Interned` at step 5 when the `Interned` is moved into the vec, which means the borrow made at 4 is untracked when Miri executes the debug assertions. The fix here is to make the assignment/move of the `Interned` happen first so Miri doesn't retag the inner `Box<T>`. This is accomplished by reordering the `self.vec.push` operation to immediately follow step 3. An additional unchecked index into the vec is used to get a shared access to that `Interned` object to later derive the `&'static T`. This commit also adds an additional test to resolve a slice from the symbol table to ensure Miri does not disagree as the `Interned` is moved during growth of the `SymbolTable`. Fixes #235.
lopopolo
added a commit
that referenced
this issue
Jul 26, 2023
This stacked borrows violation impacts all `SymbolTable` variants in this crate and has been present in all published versions. The `SymbolTable::intern` function previously worked like this: 1. Convert the given contents to be interned into a `Cow<'static, T>`. 2. Check to see if this content is already interned by checking the internal bimap. If found, return the matching symbol. 3. Convert the `Cow` into an `Interned` which is an enum of either a &'static T` or a `Box<T>`. 4. Borrow a `&'static T` from the `Interned`. 5. Push the `Interned` into the vec. 6. Add the `&'static T` to the map. 7. Check that the insertion happened correctly with some debug assertions. 8. Return the computed symbol. As of at least rustc 1.73.0-nightly (31395ec38 2023-07-24), Miri pops all borrows from the `Interned` at step 5 when the `Interned` is moved into the vec, which means the borrow made at 4 is untracked when Miri executes the debug assertions. The fix here is to make the assignment/move of the `Interned` happen first so Miri doesn't retag the inner `Box<T>`. This is accomplished by reordering the `self.vec.push` operation to immediately follow step 3. An additional unchecked index into the vec is used to get a shared access to that `Interned` object to later derive the `&'static T`. This commit also adds an additional test to resolve a slice from the symbol table to ensure Miri does not disagree as the `Interned` is moved during growth of the `SymbolTable`. Fixes #235.
lopopolo
added a commit
that referenced
this issue
Jul 26, 2023
This stacked borrows violation impacts all `SymbolTable` variants in this crate and has been present in all published versions. The `SymbolTable::intern` function previously worked like this: 1. Convert the given contents to be interned into a `Cow<'static, T>`. 2. Check to see if this content is already interned by checking the internal bimap. If found, return the matching symbol. 3. Convert the `Cow` into an `Interned` which is an enum of either a &'static T` or a `Box<T>`. 4. Borrow a `&'static T` from the `Interned`. 5. Push the `Interned` into the vec. 6. Add the `&'static T` to the map. 7. Check that the insertion happened correctly with some debug assertions. 8. Return the computed symbol. As of at least rustc 1.73.0-nightly (31395ec38 2023-07-24), Miri pops all borrows from the `Interned` at step 5 when the `Interned` is moved into the vec, which means the borrow made at 4 is untracked when Miri executes the debug assertions. The fix here is to make the assignment/move of the `Interned` happen first so Miri doesn't retag the inner `Box<T>`. This is accomplished by reordering the `self.vec.push` operation to immediately follow step 3. An additional unchecked index into the vec is used to get a shared access to that `Interned` object to later derive the `&'static T`. This commit also adds an additional test to resolve a slice from the symbol table to ensure Miri does not disagree as the `Interned` is moved during growth of the `SymbolTable`. Fixes #235.
lopopolo
added a commit
that referenced
this issue
Jul 26, 2023
lopopolo
added a commit
that referenced
this issue
Jul 26, 2023
This stacked borrows violation impacts all `SymbolTable` variants in this crate and has been present in all published versions. The `SymbolTable::intern` function previously worked like this: 1. Convert the given contents to be interned into a `Cow<'static, T>`. 2. Check to see if this content is already interned by checking the internal bimap. If found, return the matching symbol. 3. Convert the `Cow` into an `Interned` which is an enum of either a &'static T` or a `Box<T>`. 4. Borrow a `&'static T` from the `Interned`. 5. Push the `Interned` into the vec. 6. Add the `&'static T` to the map. 7. Check that the insertion happened correctly with some debug assertions. 8. Return the computed symbol. As of at least rustc 1.73.0-nightly (31395ec38 2023-07-24), Miri pops all borrows from the `Interned` at step 5 when the `Interned` is moved into the vec, which means the borrow made at 4 is untracked when Miri executes the debug assertions. The fix here is to make the assignment/move of the `Interned` happen first so Miri doesn't retag the inner `Box<T>`. This is accomplished by reordering the `self.vec.push` operation to immediately follow step 3. An additional unchecked index into the vec is used to get a shared access to that `Interned` object to later derive the `&'static T`. This commit also adds an additional test to resolve a slice from the symbol table to ensure Miri does not disagree as the `Interned` is moved during growth of the `SymbolTable`. Fixes #235.
lopopolo
added a commit
that referenced
this issue
Jul 26, 2023
See #235, #236. See #236 (comment). Introduce a new `PinBox` type which stores a boxed slice as a `NonNull` pointer. The pointer is converted back to a `Box` on drop.
lopopolo
added a commit
that referenced
this issue
Jul 26, 2023
See #235, #236. See #236 (comment). Introduce a new `PinBox` type which stores a boxed slice as a `NonNull` pointer. The pointer is converted back to a `Box` on drop.
amousset
pushed a commit
to rustsec/advisory-db
that referenced
this issue
Jul 26, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-interner
Area: String interners, data structures, and types.
A-security
Area: Security vulnerabilities and unsoundness issues.
C-bug
Category: This is a bug.
E-help-wanted
Call for participation: Help is requested to fix this issue.
https://github.com/artichoke/intaglio/actions/runs/5663120563/job/15344308090
The text was updated successfully, but these errors were encountered: