News for hackers. Stuff that matters.
Re:Data Race Patterns in Go by Groxx on Saturday June 11, 2022 @02:03PM (#31706593)
When printing s1, s2, then s3:

It does exactly that, yes: https://go.dev/play/p/rs2FeK_QUjs

    [a b c]
    [a b c x]
    [a b c y]
But maybe it doesn't: https://go.dev/play/p/Na-eL0sOV9e

    [a b c]
    [a b c y]  <- this is now "y"
    [a b c y]
So... maybe they share the same backing array? Lets try setting s2[0] to "z" after appending with the original code: https://go.dev/play/p/mAB-gUb0shB

    [a b c]
    [z b c x]
    [a b c y]
Apparently not. But also apparently yes? https://go.dev/play/p/k1ciGzyS2gc

    [z b c]    <- this changed too
    [z b c y]
    [z b c y]
Let's try appending just one more item before redoing ^ that example, where they all shared the same data: https://go.dev/play/p/5JneXHMeUjx

    [a b c]
    [z b c x x2]
    [a b c y y2]
Notice that in all of these examples, I haven't explicitly declared a length or capacity. There's nothing "funny looking" or clearly intentionally allowing these different behaviors, it's just simple, very-common slice use.

.... so yeah. This is a source of a number of hard-to-track-down bugs.

Re:Data Race Patterns in Go by Jcowell on Sunday June 12, 2022 @04:22PM (#31717929)
Is there a bug or issue on this in their GitHub cause wtf is this ?
Re:Data Race Patterns in Go by Groxx on Sunday June 12, 2022 @04:31PM (#31717987)
This is expected behavior. It's just an easy thing to screw up by accident.
Re:Data Race Patterns in Go by sethammons on Saturday June 11, 2022 @03:24PM (#31707417)
Amazing, very interesting