tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Memory corruption after fork, only on AMD CPUs



Hi all,

There appears to be a memory corruption bug that only happens on AMD
CPUs running NetBSD (or OpenBSD). The same code doesn't fail on Intel.
This affects Go and they've made some bug reports investigating it[1][2].

People have narrowed it down to this simple Go reproducer
(install lang/go117 to run it).

#!/bin/sh

cat << EOF > test.go
package main

import (
        "os/exec"
)

func main() {
        sem := make(chan struct{}, 100)
        for {
                sem <- struct{}{}
                go func() {
                        err := exec.Command("/usr/bin/true").Run()
                        if err != nil {
                                panic(err)
                        }
                        <-sem
                }()
        }
}
EOF
go117 run test.go


After some time, I get crashes, example output:
http://coypu.sdf.org/go-stack-trace-AMD.log
http://coypu.sdf.org/go-stack-trace-AMD2.log
http://coypu.sdf.org/go-stack-trace-AMD3.log

Upstream Go has stated about one of the *OpenBSD* stack traces:

    That looks very much like a forked child process is changing the
    memory seen by the parent process. Which should of course be
    impossible.

I suspect this is a missing AMD Ryzen errata or a UVM bug specific to
an AMD feature.
Does anyone have any suggestions for what may be the cause of this bug?

I can reproduce this bug, happy to test out prospective diffs.
My machine: Ryzen 3600, runs NetBSD 9.99.92.

Thanks.

[1] https://github.com/golang/go/issues/49209
[2] https://github.com/golang/go/issues/34988 (says OpenBSD,
same is true for NetBSD)



Home | Main Index | Thread Index | Old Index