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

Fix undefined behaviour using .get on unique_ptr #1386

Merged
merged 1 commit into from
Jul 15, 2022

Conversation

philberty
Copy link
Member

As the move semantics for AST and HIR crates are unsafe on older compilers
we are working around this by storing the pointer into the mappings class
this was using the get method to store the pointer. The issue for loading
extern crates the unique_ptr goes out of scope and this the deletion code
resulting in undefined behaviour. This changes it to call release to take
full ownership of the pointer as we expect.

As the move semantics for AST and HIR crates are unsafe on older compilers
we are working around this by storing the pointer into the mappings class
this was using the get method to store the pointer. The issue for loading
extern crates the unique_ptr goes out of scope and this the deletion code
resulting in undefined behaviour. This changes it to call release to take
full ownership of the pointer as we expect.
@philberty philberty added this to the Imports and visibility milestone Jul 15, 2022
@philberty philberty self-assigned this Jul 15, 2022
@philberty
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Jul 15, 2022

Build succeeded:

@bors bors bot merged commit 0a9416f into master Jul 15, 2022
@philberty philberty deleted the phil/undefined-behaviour branch July 15, 2022 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant