Re:Gotchas, Irritants and Warts in Go Web Development
by eurleif on Thursday March 07, 2013 @07:13PM
(#5341313)
How do you expect them to do that when the language doesn't allow it? Can you show an example of Go code which creates an invalid pointer?
[ Parent
| on HN ]
Re:Gotchas, Irritants and Warts in Go Web Development
by Symmetry on Thursday March 07, 2013 @08:32PM
(#5341618)
There's a library called "unsafe" explicitely for this. I think it's reasonable to expect people to generally not use it, though.
Re:Gotchas, Irritants and Warts in Go Web Development
by eurleif on Thursday March 07, 2013 @08:37PM
(#5341638)
As far as I know, it can only create a pointer of type A that actually points to a value of type B, not reference unallocated/deallocated memory. Nullable<T> could do that too if the language allowed it.
Re:Gotchas, Irritants and Warts in Go Web Development
by lagom on Thursday March 07, 2013 @10:19PM
(#5341906)
It's definitely possible to access unallocated memory e.g.,
// p points to address 1000
p := (*int)(unsafe.Pointer(uintptr(1000)))
Of course, this is why use of the unsafe package is heavily discouraged.
Re:Gotchas, Irritants and Warts in Go Web Development
by kevingadd on Thursday March 07, 2013 @11:34PM
(#5342102)
Any language that lets you call out into third-party libraries not written in that language can end up with heap corruption.
The important distinction is that a 'Nullable' value type need not involve a pointer, which means it can entirely live on the stack, which dramatically limits the damage that can be done by corruption: Worst case, corruption sets the 'hasValue' flag to true, and you read an uninitialized struct off the stack. Much less catastrophic than a double-free or pointer into random memory (Though, of course, a determined attacker could probably make do with either).