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: mheap.busyList use unproper len when return list from h.busy #18944

zhaozhiqianghw opened this issue Feb 5, 2017 · 4 comments


None yet
4 participants
Copy link

commented Feb 5, 2017

Please answer these questions before submitting your issue. Thanks!

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


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

linux amd64

The definition of mheap.busyList locate in mheap.go:943 as followed:

func (h *mheap) busyList(npages uintptr) *mSpanList {
if npages < uintptr(len( {
return &h.busy[npages]
return &h.busylarge

When check if it can return the busy list using "len(free)", I think it's not proper.
Although the current version of Go set the same lenght of and h.busy, it's different.

The same puzzle occurs at the definition of mheap.alloc_m @ mheap.go:592:
if large {
atomic.Xadd64(&memstats.heap_live, int64(npage<<_PageShift))
// Swept spans are at the end of lists.
if s.npages < uintptr(len( {
} else {

So it's a mistake, or it's some design.

@ianlancetaylor ianlancetaylor added this to the Go1.9 milestone Feb 5, 2017


This comment has been minimized.

Copy link

commented Feb 5, 2017


This comment has been minimized.

Copy link

commented Feb 5, 2017

This is a little obtuse, but I wouldn't call it a bug. The free and busy lists must have the same length since we move short spans back and forth between these two lists.

It would be perfectly reasonable to change both of these to len(h.busy).


This comment has been minimized.

Copy link

commented Feb 5, 2017

Yes, this is not a bug. It's better for reading.


This comment has been minimized.

Copy link

commented Feb 6, 2017

CL mentions this issue.

@gopherbot gopherbot closed this in 77f64c5 Mar 3, 2017

@golang golang locked and limited conversation to collaborators Mar 3, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.