4 ms·
> If you use `nokogiri` in Ruby and get a segfault, that is a bug in nokogiri. It is not an indication that Ruby is unsafe. Rust has a strict definition of saf
by shadowmint 12y ago
> If you use `nokogiri` in Ruby and get a segfault, that is a bug in nokogiri. It is not an indication that Ruby is unsafe.
Rust has a strict definition of safety; not all rust code for fills that guarantee.
We're not talking fast and loose here. These are absolute definitions.
You can write safe code that crashes in rust. That absolutely violates the safety guarantee whatever the reason for it.
> This is in the process of being eliminated
No it's not.
Keep dynamic drop semantics, by having each function maintain a (potentially empty)
set of auto-injected boolean flags for the drop obligations for the function that need
to be tracked dynamically (which we will call "dynamic drop obligations").
What's happening is some of the run time overhead is being reduced.
- wycats 12y ago> You can write safe code that crashes in rust. That absolutely violates the safety guarantee whatever the reason for it. You can write Ruby code that calls into unsafe C code and SEGVs. This is a bug in the C code you called. It should have exposed a safe interface. You can write Rust code that calls into clearly delineated unsafe code and SEGVs. This is a bug in the unsafe code you called. It should have exposed a safe interface. Anything to the contrary is a misunderstanding of the purpose and role of unsafe code in Rust, and endangers the entire ecosystem, just as it would endanger the Ruby ecosystem if it were seen as normal for C extensions to SEGV the safe Ruby process.
- nwmcsween 12y ago'Unsafe' is a bad term, effect is much better and it is most definitely a rust issue. If the language doesn't have a way of dealing with effects it won't be able to handle them. Rust is honestly a more safe c++ and in my opinion not an alternative for c.
- wycats 12y agoI don't know what this means. I stand by my upstream comment.
- TheHydroImpulse 12y agoAlgebraic effects system.
- shadowmint 12y agoI'm not arguing any of these points. I'm just saying there are these two misconceptions: - if you write safe rust code, your code can't segfault This isn't true if your code path contains any unsafe code. - Rust code can't segfault This isn't true at all. Sure, if it does segfault its a bug in the c code / unsafe code. You're absolutely correct. ...but bugs aren't deliberate. Obviously no one is going to deliberately expose a c api that has segfaults in it. The misconception is that if you're using rust you're safe from the bugs that other programmers may have made... which is not true. There's a trust chain involved; if you depend on a library you trust it's bug free and won't delete your harddisk and crash your program, but there's a difference between trusting a library is not malicious, and trusting a library is bug free. If you have to trust the library is bug free, you're really no better off than using C++ are you? ...but people keep saying that if you use rust then there are certain types of safety that are guaranteed by the language: http://doc.rust-lang.org/reference.html#behavior-considered-unsafe http://doc.rust-lang.org/reference.html#behavior-considered-..., regardless of programmer bugs. It's just not true. Once again, I'm not arguing that safety is good or bad or whatever. My assertion is very very specific: Rust code written 100% safely can crash if it has a dependency that uses unsafe code. The assertion that 100% safely written rust code with arbitrary dependencies can't crash is false.
- dbaupp 12y ago> The misconception is that if you're using rust you're safe from the bugs that other programmers may have made... which is not true. Of course it's not true, but the libraries you're using will (hopefully, for the most part) be written in Rust, which increases the level of trust. > There's a trust chain involved; if you depend on a library you trust it's bug free and won't delete your harddisk and crash your program, but there's a difference between trusting a library is not malicious, and trusting a library is bug free. > If you have to trust the library is bug free, you're really no better off than using C++ are you? The libraries are written in Rust, so have all the benefits of that. It is nonsense to say that "libraries can have bugs so you might as well use C++".
- shadowmint 12y ago
- dbaupp 12y ago> No it's not. > What's happening is some of the run time overhead is being reduced. I believe wycats was responding specifically to > Rust uses 'drop flags', which are extra bytes at the end of struct instances in memroy, to track objects and keep meta information about them to determine if they should be dropped. And these are being eliminated. That is the drop flag will be entirely separate to the struct instance, and will only be injected into stack frames where there is a conditional branch in which a value is moved out in one, but not the other, e.g. let x = some_value; if condition { drop(x); } else { /* do nothing */ } then `x` will get a drop flag as a single bit (or byte) on the stack. If the code is changed to if condition { drop(x); } else { drop(x) } there will be no drop flag, and no overhead. Furthermore, placing the value on to the heap, e.g. `box some_value`, will not have an associated drop flag for `some_value`, that is, eliminating the byte that is currently stored with it.
- shadowmint 12y agoWhatever, there are still drop flags (on the stack instead, sure), and still dynamic runtime checks for drops. The points I was making is that 'zero cost' memory management isn't 100% zero cost. The drop checker does incur some basic dynamic runtime costs. To be 'zero cost' drop behaviour would be determined at compile time.
- dbaupp 12y agoThe behaviour is determined at compile time, with runtime cost only introduced if it is absolutely needed (when one branch drops, and another doesn't), and, even then, it can be avoided, by manually forcing a drop of the value in every branch.