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: nacl/amd64p32's IndexByte overflow on extremely large lengths #24187

Closed
josharian opened this issue Mar 1, 2018 · 1 comment
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@josharian
Copy link
Contributor

package main

import (
	"bytes"
	"fmt"
	"unsafe"
)

func main() {
	b := make([]byte, 128)
	for i := range b {
		b[i] = 1
	}
	if bytes.IndexByte(b, 0) != -1 {
		panic("found 0")
	}
	for i := range b {
		b[i] = 0
		c := b
		*(*int)(unsafe.Pointer(uintptr(unsafe.Pointer(&c)) + unsafe.Sizeof(uintptr(0)))) = 1<<31 - 1
		if bytes.IndexByte(c, 0) != i {
			fmt.Printf("missing 0 at %d\n", i)
		}
		b[i] = 1
	}
}

This succeeds with GOOS=darwin GOARCH=amd64 and GOOS=darwin GOARCH=386 but fails with GOOS=nacl GOARCH=amd64p32 for all i >= 15.

The problem is overflow in runtime·indexbytebody.

This is what was causing the trybot failures in CL 97523.

@josharian josharian added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 1, 2018
@josharian josharian added this to the Go1.11 milestone Mar 1, 2018
@josharian josharian self-assigned this Mar 1, 2018
@gopherbot
Copy link

Change https://golang.org/cl/97802 mentions this issue: runtime: fix amd64p32 indexbytes in presence of overflow

@golang golang locked and limited conversation to collaborators Mar 1, 2019
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.
Projects
None yet
Development

No branches or pull requests

2 participants