News for hackers. Stuff that matters.
Re:Why Go Is Not Good by richo on Sunday June 29, 2014 @09:58PM (#7963311)
that's what mapping an -rwx page at 0x0 does, and as a result it segfaults, which is an access violation.
Re:Why Go Is Not Good by dbaupp on Sunday June 29, 2014 @11:14PM (#7963513)
There is some subtlety about dereferencing a null pointer. Many languages (C, C++, Rust) state that *NULL is undefined behaviour, that is, the compiler can assume that it never happens and optimises based on this. This can lead to a "misoptimised" program that doesn't actually segfault when the source suggests it should.

http://blog.llvm.org/2011/05/what-every-c-programmer-should-...

Re:Why Go Is Not Good by jjnoakes on Sunday June 29, 2014 @11:15PM (#7963515)
No, you are wrong.

First, mapping that page doesn't cause all null pointer dereferences to segfault.

And second, the language doesn't require a segfault. In fact, it explicitly permits the implementation to do whatever it likes.

That is the difference between safe and unsafe. It is in the language definition.

Re:Why Go Is Not Good by dbaupp on Monday June 30, 2014 @12:00AM (#7963635)
"the language"... which one? AIUI, Go doesn't state that null dereferences are undefined behaviour, but rather that they are guaranteed to panic.
Re:Why Go Is Not Good by richo on Monday June 30, 2014 @12:27AM (#7963696)
"The language" ?

C doesn't define behaviour of a null deref, but most compilers map a -rwx page there to ensure that attempts to deref fault.

In what circumstance do they not?

Re:Why Go Is Not Good by dbaupp on Monday June 30, 2014 @12:51AM (#7963743)
The compilers don't map pages there, the operating system does. The problem is the compiler will optimise assuming that a null deref never happens, so you can have source that looks like it should crash due to a null deref, but the compiler has "misoptimised" it to have very different behaviour.

http://blog.llvm.org/2011/05/what-every-c-programmer-should-...

Re:Why Go Is Not Good by Dewie on Monday June 30, 2014 @02:01AM (#7963880)
...I'm talking about throwing an exception or something similar, not getting a segfault. Like in Java.