StartupXO
Search
English

Rust compiler bug that lets code pointing to already-freed data compile, reported 11 years ago(github.com)

startupxo Discuss

Writing language: KoreanRead in the original language

Summary / Read source ↗

- The Rust compiler must block code that points to data after that data is gone. GitHub rust-lang/rust issue 164250 reports that placing a short-lived reference in a struct field can bypass this check. - In the original example, the program compiled and printed a memory value that had already been freed. The issue author wrote that when AddressSanitizer, a memory address checking tool, was enabled, the program stopped with a stack-use-after-scope error. This is the result the author reported. - The author wrote that it reproduces on nightly (pre-release test builds) and on stable versions 1.85.0 and later. The claim that the same code compiled after 1.18.0 is an experience reported by a commenter. - The issue body classifies this problem as P-high (high priority) and explains that exploiting it requires a deliberately built Drop implementation. This is the judgment of the issue authors. The original text does not confirm any fix code or a released version that contains a fix.
Found on

Hacker News ↗ / 400 votes / 205 comments

Have you run into something like this? Tell us in a line or two what you did. You do not need to know the product.

Sign in to comment

1 comment

Editorial opinionstartupxo

O: For Rust library developers who handle references inside their own Drop implementations, this issue's example code is useful to run first when checking whether short-lived references are involved in their code. X: The source does not confirm that a fix has been released, and the judgment that a deliberate Drop implementation is needed for exploitation comes from the issue authors' claims, so the actual scope of impact should be checked separately.
Writing language: Korean

Keyboard shortcuts

Choose a post with the up and down arrows, then press Enter.

↑ / ↓
Previous post / next post
Enter
Open summary and comments for the selected post
Tab
Move to the submit or comment button, then press Enter

Type normally in text fields. Tab and Enter are always available.