Earlier quoted context omitted.
Re: parameterized unsafe -- I think it's been discussed and rejected, I don't remember where. I think it was mostly a matter of "yes this would be more powerful, but the complexity isn't worth it". Note that we sort of made a "new" kind of unsafe with the UnwindSafe trait: https://doc.rust-lang.org/std/panic/trait.UnwindSafe.html That's probably how we intend to solve these kinds of problem in the future. Re: aliasin…
> Someone will develop a version of asan/ubsan for Rust. This already happened (japaric [1]). But ASan won't save you from a bug due to optimization-because-I-assumed-these-locations-dont-alias (maybe TSan might?). [1] https://users.rust-lang.org/t/howto-sanitize-your-rust-code/...
Bugs You'll Probably Only Have in Rust
11–20 of 91 posts
Re: Bugs You'll Probably Only Have in Rust
#12Earlier quoted context omitted.
> Someone will develop a version of asan/ubsan for Rust. This already happened (japaric [1]). But ASan won't save you from a bug due to optimization-because-I-assumed-these-locations-dont-alias (maybe TSan might?). [1] https://users.rust-lang.org/t/howto-sanitize-your-rust-code/...
As you say, none of the existing sanitisers catch Rust-specific problems, which is, I assume, what the parent meant by "for Rust". That said, they will likely catch many of the consequences of such violations, just not pinpoint the cause as precisely.
Re: Bugs You'll Probably Only Have in Rust
#13Earlier quoted context omitted.
As you say, none of the existing sanitisers catch Rust-specific problems, which is, I assume, what the parent meant by "for Rust". That said, they will likely catch many of the consequences of such violations, just not pinpoint the cause as precisely.
A Rust-specific sanitizer has been proposed, though. See my other reply (which I was in the middle of writing when this thread popped up, so I didn't see it): https://news.ycombinator.com/item?id=14553679
It is definitely an important missing piece to bridge the gap to ASan/TSan, but it's still just a proposal/work in progress, not least because, AIUI, the precise rules it needs to enforce aren't yet entirely clear.
Re: Bugs You'll Probably Only Have in Rust
#14are SJWs counted as a bug?
Re: Bugs You'll Probably Only Have in Rust
#15> Making unsafe a big scary "all bets are off" button is only compelling if most of our users don't need to use that button. Rust is trying to be a language for writing concurrent applications, so sharing your type between threads requiring unsafe would be really bad. It would be neat if we could decompose unsafe like so "unsafe[this_feature,that_feature] {}". The unqualified "unsafe" could still refer to a global "f…
> It would be neat if we could decompose unsafe like so "unsafe[this_feature,that_feature] {}" I sometimes feel the same way, but remember that the `unsafe` keyword only unlocks four additional features: 1. Dereferencing a raw pointer 2. Calling an unsafe function or method 3. Accessing or modifying a mutable static variable (and this might conceivably even be removed entirely someday) 4. Implementing an unsafe trait…
Mutable static variables removed or the unsafety of accessing them? Didn't Rust, at one early point, not allow mutable global variables?
Re: Bugs You'll Probably Only Have in Rust
#16Earlier quoted context omitted.
> It would be neat if we could decompose unsafe like so "unsafe[this_feature,that_feature] {}" I sometimes feel the same way, but remember that the `unsafe` keyword only unlocks four additional features: 1. Dereferencing a raw pointer 2. Calling an unsafe function or method 3. Accessing or modifying a mutable static variable (and this might conceivably even be removed entirely someday) 4. Implementing an unsafe trait…
> 3. Accessing or modifying a mutable static variable (and this might conceivably even be removed entirely someday) Mutable static variables removed or the unsafety of accessing them? Didn't Rust, at one early point, not allow mutable global variables?
Re: Bugs You'll Probably Only Have in Rust
#17Re: Bugs You'll Probably Only Have in Rust
#18Earlier quoted context omitted.
> It would be neat if we could decompose unsafe like so "unsafe[this_feature,that_feature] {}" I sometimes feel the same way, but remember that the `unsafe` keyword only unlocks four additional features: 1. Dereferencing a raw pointer 2. Calling an unsafe function or method 3. Accessing or modifying a mutable static variable (and this might conceivably even be removed entirely someday) 4. Implementing an unsafe trait…
> 3. Accessing or modifying a mutable static variable (and this might conceivably even be removed entirely someday) Mutable static variables removed or the unsafety of accessing them? Didn't Rust, at one early point, not allow mutable global variables?
Re: Bugs You'll Probably Only Have in Rust
#19Question for the rust folks - are there any features that wouldn't have been possible without "unsafe"? That is, if rust never had unsafe, would it have been fundamentally limited in any way? Or is it required for e.g. interoperability with C?
let p = 0xb8000 as *mut u8;
VGA drivers use the memory mapped at 0xb8000 to drive the device. This creates a pointer, p, at that address.In order to demonstrate this is safe (okay so unsafe isn't in this example, creating p is safe, but writing to/reading from it is not), a language would have to know:
1. That your code is running in kernel mode, that is the entire concept of ring 0 vs ring 3.
2. That the VGA spec specifies that location in memory.
Yeah, in _theory_, you could have a language that does this, but that'd tie your language so, so, so deeply to each platform, that it's not feasible.
This can be extrapolated to all kinds of other low-level things.
Re: Bugs You'll Probably Only Have in Rust
#20Question for the rust folks - are there any features that wouldn't have been possible without "unsafe"? That is, if rust never had unsafe, would it have been fundamentally limited in any way? Or is it required for e.g. interoperability with C?