shadow / shadow

Shadow is a discrete-event network simulator that directly executes real application code, enabling you to simulate distributed systems with thousands of network-connected processes in realistic and scalable private network experiments using your laptop, desktop, or server running Linux.

Home Page:https://shadow.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go tests segfault with Go 1.21 (Fedora 38 and 39)

stevenengler opened this issue · comments

On fedora 39, programs linked with -linkshared (which is required by shadow) segfault on simple io function calls. For example:

sudo docker run --rm -it fedora:39
dnf update -y
dnf install -y golang
go install -buildmode=shared -linkshared std
cd /tmp
cat <<EOF >> foo.go
package main

import (
    "fmt"
)

func main() {
    fmt.Println("hello")
}
EOF
go build -linkshared -o foo foo.go
./foo
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7f4ce37148b3]

goroutine 1 [running]:
os.(*File).write(...)
	/usr/lib/golang/src/os/file_posix.go:46
os.(*File).Write(0x0, {0xc000014088?, 0x6, 0x7f4ce3620145?})
	/usr/lib/golang/src/os/file.go:183 +0x53
fmt.Fprintln({0x403b68, 0x0}, {0xc000354720, 0x1, 0x1})
	/usr/lib/golang/src/fmt/print.go:305 +0x6f
fmt.Println(...)
	/usr/lib/golang/src/fmt/print.go:314

If built without the -linkshared flag, then it completes successfully.

For the shadow tests, this results in:

The following tests FAILED:
	 60 - simple_http-shadow (Failed)
	 61 - gc-linux (Failed)
	 62 - gc-shadow (Failed)
	 64 - goroutines-linux (Failed)
	 65 - goroutines-shadow (Failed)

Adding an os import magically makes the example above work again:

import (
    _ "os"
    "fmt"
)

Opened an issue at golang/go#64925.

fixed on tip / 1.22rc1

Apparently this will be fixed in Go 1.22, so we'll probably need to add a note for fedora 39 to build using an older (or newer once 1.22 is released in February) version of Go, and not the version from the fedora repository.

We should probably also add a CMake check that shows an error message on Go 1.21 if the --extra build flag is used.

Edit: Confirmed that the bug doesn't exist in Go 1.20, so this exists only in 1.21.x.

I confirmed that the above example still fails with Go 1.21.7 on Fedora 39, but if you install Go 1.22.1 from the Go website and run go install -buildmode=shared std, then the above example runs correctly. I also confirmed that the Shadow Go tests pass on Fedora 39 when built using Go 1.22.1.

I think we should just skip supporting Fedora 39 since it ships with a broken Go version. Fedora 40 will be released in April and will presumably have Go 1.22 or newer. Instead we should somehow add a CMake check that Go 1.21.x is not installed if ./setup build --extra is used.

Fedora has upgraded the version of Go on Fedora 38 from 1.20 to 1.21, so Shadow's Go tests now also fail on Fedora 38. I've updated the title to reflect this.