Skip to content
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

cmd/link: crash on undef symbol when external linking #47993

Closed
thanm opened this issue Aug 26, 2021 · 1 comment
Closed

cmd/link: crash on undef symbol when external linking #47993

thanm opened this issue Aug 26, 2021 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Soon This needs to be done soon. (regressions, serious bugs, outages)

Comments

@thanm
Copy link
Contributor

thanm commented Aug 26, 2021

What version of Go are you using (go version)?

Using tip.

$ go version
go version devel go1.18-b5498bb297 Thu Aug 26 15:07:04 2021 -0400 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

linux/amd64

What did you do?

Build this code:

package main

type M struct {
	b bool
}

func (m *M) run(fp func())

func doit(m *M) {
	m.run(func() {
	})
}

func main() {
	m := &M{true}
	doit(m)
}

with

go build -ldflags="-linkmode=external" m.go

What did you expect to see?

Error about main.(*M).run being undefined, but no crash.

What did you see instead?

Crash with:

# command-line-arguments
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x5509b6]

goroutine 34 [running]:
cmd/link/internal/ld.(*relocSymState).relocsym(0xc00016ee98, 0x7, {0x7f4fb3f3ef60, 0x58, 0x1603e5})
	/w/ygo/src/cmd/link/internal/ld/data.go:441 +0x1816
cmd/link/internal/ld.writeBlock(0xc000150000, 0xc000e937b0, 0xc000586000, {0xc000172000, 0xdd1, 0x0}, 0xc000135598, 0x0, {0x86b240, 0x200, ...})
	/w/ygo/src/cmd/link/internal/ld/data.go:995 +0x390
cmd/link/internal/ld.writeBlocks.func1(0xc000ff1000, 0x44d, {0xc000172000, 0x60000c000e937d0, 0x12}, 0xc000e88250, 0xc000158d80, {0x86b240, 0x200, 0x200})
	/w/ygo/src/cmd/link/internal/ld/data.go:951 +0x76
created by cmd/link/internal/ld.writeBlocks
	/w/ygo/src/cmd/link/internal/ld/data.go:950 +0x57c
@thanm thanm added NeedsFix The path to resolution is known, but the work has not been done. Soon This needs to be done soon. (regressions, serious bugs, outages) labels Aug 26, 2021
@thanm thanm self-assigned this Aug 26, 2021
@gopherbot
Copy link

Change https://golang.org/cl/345473 mentions this issue: cmd/link: avoid crash on undefined func sym with external linking

@rsc rsc unassigned thanm Jun 23, 2022
@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Soon This needs to be done soon. (regressions, serious bugs, outages)
Projects
None yet
Development

No branches or pull requests

2 participants