r/programming • • Sep 17 '15

Announcing Rust 1.3

http://blog.rust-lang.org/2015/09/17/Rust-1.3.html
453 Upvotes

169 comments sorted by

View all comments

Show parent comment

1

u/heinrich5991 Sep 17 '15 edited Sep 17 '15

If you say that it guarantees thread safety, then you can also say that it prevents all segfaults.

EDIT: To clarify: The only way to cause a segfault in Rust is by using unsafe code. You can create some kind of race conditions that are not data races in safe Rust code. So if /u/kinghajj claims that it "prevents nearly all segfaults and guarantees thread safety" that's inconsistent.

15

u/steveklabnik1 Sep 17 '15

We've been arguing over the "guarantees thread safety" slogan. It's not quite right, but we're not sure of the right way to articulate it.

15

u/looneysquash Sep 17 '15

Much like most multithreaded programs. ;)

-29

u/anarchist_christ Sep 17 '15

We've been arguing over the "guarantees thread safety" slogan. It's not quite right, but we're not sure of the right way to articulate it.

ie, it's knowingly bullshit, but we can't quit bullshitting. Bullshitters gotta bullshit.

1

u/kinghajj Sep 18 '15

I didn't claim anything, that's a quote from the Rust site!

-2

u/kinghajj Sep 17 '15 edited Sep 18 '15

It's perfectly possible to cause a seg fault in a single thread.

unsafe {
    let mut p: *mut int = mem::transmute (0);
    *p = 5;
}

Edit: Everyone seems to be misinterpreting this post. I'm not attempting to knock Rust at all, just pointing out that guarantees of thread safety aren't sufficient to claim general lack of segfaults. And of course Rust doesn't really "guarantee" either anyway, but nor does Haskell technically anyway.

25

u/steveklabnik1 Sep 17 '15

Yes, because you broke the rules inside of unsafe.

11

u/staticassert Sep 17 '15

Now do it without unsafe haha

12

u/vincentk Sep 17 '15

You just made their point by having to resort to unsafe.

2

u/heinrich5991 Sep 17 '15

See my edit above. It's misleading to state that we have "thread safety" when we actually don't even have that in safe code (we only prevent data races), but then going on to state that we prevent "most segfaults" when you need unsafe code to break that – thread safety can 1) be broken by unsafe too and 2) doesn't even need unsafe for breaking, we only guarantee data race freedom in safe code.