Comment by uluyol

Comment by uluyol 9 days ago

7 replies

Go very much is memory safe in the absence of data races.

Data races cause issues in all languages, though it's fair to say that Go is affected slightly more than languages like Java. Rust is a bit special by making data races hard to trigger (impossible in safe code IIUC), but this is not typical.

pjmlp 9 days ago

Kind of, regarding Rust.

It is impossible in the context of having all threads accessing in-process memory.

If the data can be accessed externally, regardless of the guarantees being uphold on the Rust side, there are no guarantees from third parties accessing the same data.

It also doesn't prevent other race issues with external data.

  • galangalalgol 9 days ago

    Memory like that needs to be wrapped with unsafe for access, there is the volotile crate to mark stuff like that so the compuler won't optimize it away.

    Other than rust haskell seems like the other primary candidate for memory safety even across threads.

    • pjmlp 9 days ago

      Yes, but it doesn't guarantee changes occurring from third parties, even if everything is done correctly on Rust side, and all invariants are correct, so corrupted data can be still be seen as valid.

      • galangalalgol 9 days ago

        Is there any defense at all against what you are talking about? I mean, I could use a firewire controller to modify memory without the processor or OS being aware. I suppose you could sign every block of memory using the tpm, but you'd have to the signatures in the tpm, and the code to check the signatures, and so on.

        • pjmlp 8 days ago

          The point is that Fearless Concurrency comes with some footnotes when doing the full spectrum of systems programming.

          Which tend to be ignored when talking about how Rust is so much better than anything else.

          Ye it has improved some concurrency/parallelism scenarios, not all of them.

[removed] 9 days ago
[deleted]
kaba0 9 days ago

Yeah, and C is memory safe in absence of memory safety bugs..