All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Rust codebase fails Miri checks with dangling reference UB in unsafe slice construction

By

ndiddy

16d ago· 2 min readenCode

Summary

The article reports a Rust codebase that fails basic Miri (Undefined Behavior sanitizer) checks, specifically demonstrating a dangling reference error when constructing a slice from raw parts in unsafe code. The error occurs at src/main.rs:97 where `core::slice::from_raw_parts` is called with a pointer that has no provenance, leading to Undefined Behavior in safe Rust code.

Key quotes

· 3 pulled
error: Undefined Behavior: constructing invalid value of type &[u8]: encountered a dangling reference (0x20933[noalloc] has no provenance)
unsafe { core::slice::from_raw_parts(ptr as *const u8, self.len()) }
this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
Snippet from the RSS feed
error: Undefined Behavior: constructing invalid value of type &[u8]: encountered a dangling reference (0x20933[noalloc] has no provenance) --> src/main.rs:97:18 | 97 | unsafe { core::slice::from_ra...

You might also wanna read