Skip to content

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

@stevenengler

Description

@stevenengler

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"
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugError or flaw producing unexpected results

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions