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

runtime: checkptrAlignment crash on nil pointer #47430

Closed
mdempsky opened this issue Jul 28, 2021 · 7 comments
Closed

runtime: checkptrAlignment crash on nil pointer #47430

mdempsky opened this issue Jul 28, 2021 · 7 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@mdempsky
Copy link
Member

With Go 1.17rc1 (and probably since 4bb0847), this program crashes when run with checkptr enabled (e.g., with -race):

package main

import (
	"runtime"
	"time"
	"unsafe"
)

func main() {
	go func() {
		for {
			runtime.GC()
		}
	}()

	go func() {
		for i := 0; ; i++ {
			recurse(i % 1024)
		}
	}()

	time.Sleep(time.Second)
}

func recurse(n int) {
	// Inflate the stack so runtime.shrinkstack gets called during GC
	if n > 0 {
		recurse(n - 1)
	}

	var p unsafe.Pointer
	_ = (*int)(p)
}

Easy fix is adding an explicit nil check at the start of checkptrAlignment.

@mdempsky mdempsky added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 28, 2021
@mdempsky mdempsky added this to the Go1.17 milestone Jul 28, 2021
@mdempsky mdempsky self-assigned this Jul 28, 2021
@gopherbot
Copy link

Change https://golang.org/cl/338029 mentions this issue: runtime: don't crash on nil pointers in checkptrAlignment

@mdempsky
Copy link
Member Author

@golang/release Do I need to do anything to make sure b39e0f4 is included in Go 1.17?

It's a runtime bug that causes valid programs to sporadically fail, albeit only when checkptr is enabled (e.g., when the race detector or msan are used).

@mdempsky mdempsky reopened this Jul 28, 2021
@cagedmantis
Copy link
Contributor

@mdempsky It's marked as a release blocker which means Go 1.17 will not be released until the issue is resolved. This will probably block a second release candidate as well.

@cagedmantis
Copy link
Contributor

I realize that I didn't answer the question explicitly. The @golang/release will ensure it is included in the Go 1.17 release.

@toothrot
Copy link
Contributor

@mdempsky Is there more work to do on this issue, or is it resolved by the linked CL?

@mdempsky
Copy link
Member Author

@cagedmantis Thanks!

@toothrot The issue is fixed by b39e0f4. I just reopened for discussion purposes to make sure it wasn't missed. I think we can close it if there's no procedural reason to keep it open any more.

@toothrot
Copy link
Contributor

@mdempsky We've got it, thanks!

@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. release-blocker
Projects
None yet
Development

No branches or pull requests

4 participants