Skip to content

runtime: unexpected fault address 0 #67255

Closed
@karalabe

Description

@karalabe

Go version

go1.22.3 linux-amd64

Output of go env in your module/workspace:

Hard to say exactly, I use `golang:1.22-alpine` (latest) docker container to build a Go app and add it to an `alpine:latest` docker container to run.

What did you do?

I can reproduce this consistently (i.e. happens 100% of the time), but it is extremely deep in a live system, so I have no idea how to make a proper repro out of it.

I have the following Go code crashing:

		values := someFunc(...)

		values = append(make([][]byte, first), values...)
		values = append(values, make([][]byte, len(keys)-last)...)

The crash is in the runtime memory management. With Go 1.22.2 I got the following dump:

	unexpected fault address 0x0
	fatal error: fault
	[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x41b0f7]
	goroutine 226018 gp=0xc000e1f500 m=32 mp=0xc0079b1008 [running]:
	runtime.throw({0x1a826de?, 0xc047f3fcb8?})
		runtime/panic.go:1023 +0x5c fp=0xc047f3fc58 sp=0xc047f3fc28 pc=0x43fc3c
	runtime.sigpanic()
	    runtime/signal_unix.go:895 +0x285 fp=0xc047f3fcb8 sp=0xc047f3fc58 pc=0x4588e5
	runtime.(*mspan).typePointersOfUnchecked(0x0?, 0x0?)
	    runtime/mbitmap_allocheaders.go:202 +0x37 fp=0xc047f3fcd8 sp=0xc047f3fcb8 pc=0x41b0f7
	runtime.(*mspan).typePointersOf(0x7f20aca3af30, 0xc047ceca00, 0x0)
	    runtime/mbitmap_allocheaders.go:162 +0x45 fp=0xc047f3fd20 sp=0xc047f3fcd8 pc=0x41b065
	runtime.bulkBarrierPreWrite(0xc047ceca00, 0x0, 0x0, 0x35?)
	    runtime/mbitmap_allocheaders.go:465 +0x12d fp=0xc047f3fd90 sp=0xc047f3fd20 pc=0x41b52d
	runtime.memclrHasPointers(0xc047ceca00, 0x0)
	    runtime/mbarrier.go:371 +0x25 fp=0xc047f3fdc0 sp=0xc047f3fd90 pc=0x41a1e5
        [...]
        at this point the line is the last line from my snippet above

With Go 1.22.3 I still see the exact crash but it didn't spit out this much crash dump, only a shorter one (which 1.22.2 also spits out sometimes instead of the long one)

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x41b0f7]
goroutine 115123 [running]:
github.com/ethereum/go-ethereum/trie.(*Trie).getBatch(0xc03ad422d0, {0x2009770?, 0xc0489ab450}, {0xc0488daa88, 0x25, 0x25}, 0x7)
 	github.com/ethereum/go-ethereum/trie/trie.go:286 +0xf65

The line referenced is the same exact last line the previous crash references; a simple slice append.

What did you see happen?

Boom

What did you expect to see?

No boom

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixPendingIssues that have a fix which has not yet been reviewed or submitted.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions