4 ms·
> In Rust you can take any data structure and mutate it. What if a memory location not marked "mut" is allocated by the compiler in the executable TEXT segment
by jjtheblunt 3y ago
> In Rust you can take any data structure and mutate it.
What if a memory location not marked "mut" is allocated by the compiler in the executable TEXT segment, so the virtual memory page is itself mapped read only?
Are you certain you can get away with what you said, within the promises of the compiler?
- fweimer 3y agoThe underlying object type would still be mutable in this case, you just can't get a &mut reference to the object.
- jjtheblunt 3y agoYou get a segmentation violation if you try writing to a read-only page as in variables in a .text segment. Are we talking about different things? I'm writing Rust too (and decades of C) and feel I'm missing what you're describing, perhaps.