← Back to context

Comment by OutOfHere

9 hours ago

(removed)

Go is broadly considered to be a memory safe language.

See for example comments from tptacek like:

https://news.ycombinator.com/item?id=44672371

(The gist: memory safety is a term of art coined by security practitioners. Go, Python, Rust, Java, others: memory safe. C/C++: memory unsafe. Periodically, people in different slices of industry or academia come up with new definitions of memory safety that declare Rust or Go or other languages to be memory unsafe, but that is not by the broadly accepted definition across industry.)

  • Rust does allow you to overflow buffers, confuse types, and duplicate mutable pointers in safe code. See cve-rs.

    • No, Rust does not allow that. The current Rust compiler does, but that’s a bug that is being fixed.

      At some point in the future, a fully backwards compatible Rust compiler will report an error when you try to compile cve-rs.

      8 replies →

  • He’s very wrong about this. Just because ‘tptacek posts a lot and did security once upon a time does not make him “broad consideration”.

You can write unsafe code in Go (import unsafe), but then, you can do the same in Rust. Unsafe code is not the default, and in day to day Go i rarely see the use of the unsafe package.

  • What he probably means is data-races in go can result in memory/type unsafe accesses -- I suspect, likely due to slice types -- not sure if that is true/false.

    • Sure, but a data race is, IMHO not the same as memory safety. A data race, can be 100% memory safe, but just cause a logic bug in some program. I often see people mixing memory safety with racing. Go has bounds checks so you end up with a panic either way. Not UB.

      As an (outside go) example, Ocaml (5) promises strong memory safety, but not to be data race free. A data race is not something we can prevent, because its usually not bound by code, but by time and the race-source rarely in source-code.

      This means we have data races in http, database inserts etc. The source is usually not a concurrent task in source code-land.

      7 replies →

No idea why you're getting downvoted for true statement. Without a ? like in C# you're always at risk of a nil pointer being dereferenced

  • > like in C# you're always at risk of a nil pointer being dereferenced

    That throws a NullReferenceException