Skip to content

x/tools/gopls: crash in bgsweep #73262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
adonovan opened this issue Apr 8, 2025 · 0 comments
Open

x/tools/gopls: crash in bgsweep #73262

adonovan opened this issue Apr 8, 2025 · 0 comments
Labels
gopls/memory-corruption "can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW) gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Apr 8, 2025

#!stacks
"sigpanic" && "runtime.(*gcBits).bytep"

Issue created by stacks.

Crash in GC sweep.

// gcBits is an alloc/mark bitmap. This is always used as gcBits.x.
type gcBits struct {
	_ sys.NotInHeap
	x uint8
}

// bytep returns a pointer to the n'th byte of b.
func (b *gcBits) bytep(n uintptr) *uint8 {
	return addb(&b.x, n) <--------- SEGV
}
...
func addb(p *byte, n uintptr) *byte {
	return (*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + n))
}

Weirdly, the arm64 code for bytep (when noninlined) shows a MOVB where I would have expected a full-width load. Can someone explain it?

(NB, this disassembly is from go1.25 devel on darwin/arm64.)
runtime.(*gcBits).bytep STEXT size=16 args=0x10 locals=0x0 funcid=0x0 align=0x0 leaf
	0x0000 00000 	L2509	TEXT	runtime.(*gcBits).bytep(SB), LEAF|NOFRAME|ABIInternal, $0-16
	0x0000 00000 	L2509	FUNCDATA	$0, gclocals·g5+hNtRBP6YXNjfog7aZjQ==(SB)
	0x0000 00000 	L2509	FUNCDATA	$1, gclocals·g5+hNtRBP6YXNjfog7aZjQ==(SB)
	0x0000 00000 	L2509	FUNCDATA	$5, runtime.(*gcBits).bytep.arginfo1(SB)
	0x0000 00000 	L2509	FUNCDATA	$6, runtime.(*gcBits).bytep.argliveinfo(SB)
	0x0000 00000 	L2509	PCDATA	$3, $1
	0x0000 00000 	L2510	PCDATA	$0, $-2
	0x0000 00000 	L2510	MOVB	(R0), R27     load b.x, SEGV
	0x0004 00004 	L0980	ADD	R1, R0, R0            add n 
	0x0008 00008 	     	NOP
	0x0008 00008 	L2510	RET	(R30)
	0x0000 1b 00 80 39 00 00 01 8b c0 03 5f d6 00 00 00 00  ...9......_.....

This stack dWF4MQ was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 linux/amd64 vscode (1)

@golang/compiler

@adonovan adonovan added gopls Issues related to the Go language server, gopls. gopls/telemetry-wins NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository. labels Apr 8, 2025
@gopherbot gopherbot added this to the Unreleased milestone Apr 8, 2025
@adonovan adonovan added the gopls/memory-corruption "can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW) label Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/memory-corruption "can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW) gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

2 participants