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

bytes: Map panics with index out of range error #7577

Closed
rui314 opened this issue Mar 19, 2014 · 2 comments
Closed

bytes: Map panics with index out of range error #7577

rui314 opened this issue Mar 19, 2014 · 2 comments

Comments

@rui314
Copy link
Member

rui314 commented Mar 19, 2014

What does 'go version' print?
go version devel +2bce43d48503 Mon Mar 17 12:07:30 2014 -0700 linux/amd64


What steps reproduce the problem?

The following code panics in bytes.Map. (http://play.golang.org/p/IgyrO32L5q)

  bytes.Map(func(r rune) rune { return 1<<30 }, []byte("x"))

Error message:

  panic: runtime error: index out of range

  goroutine 1 [running]:
  runtime.panic(0x54bc0, 0x9be57)
             /tmp/sandbox/go/src/pkg/runtime/panic.c:266 +0xe0
  runtime.panicstring(0x9be57, 0xfefcc748)
             /tmp/sandbox/go/src/pkg/runtime/panic.c:489 +0x120
  runtime.panicindex()
    /tmp/sandbox/go/src/pkg/runtime/panic.c:434 +0x40
  unicode/utf8.EncodeRune(0x10300050, 0x1, 0x1, 0x40000000, 0x1, ...)
              /tmp/sandbox/go/src/pkg/unicode/utf8/utf8.go:353 +0x1c0
  bytes.Map(0x656a4, 0xfeee1f67, 0x1, 0x1, 0xfefcc748, ...)
         /tmp/sandbox/go/src/pkg/bytes/bytes.go:366 +0x2c0
  main.main()
    /tmpfs/gosandbox-bc63d79a_7c7dc2fb_396d7b70_92fdfed7_02c17ce2/prog.go:8 +0xa0
  runtime.main()
    /tmp/sandbox/go/src/pkg/runtime/proc.c:220 +0x1c0
  runtime.goexit()
    /tmp/sandbox/go/src/pkg/runtime/proc.c:1394

  goroutine 2 [syscall]:
  runtime.notetsleepg(0xfeefdf88, 0x0, 0xf8475800, 0xd)
          /tmp/sandbox/go/src/pkg/runtime/lock_sema.c:254 +0xa0
  runtime.MHeap_Scavenger()
    /tmp/sandbox/go/src/pkg/runtime/mheap.c:463 +0xc0
  runtime.goexit()
    /tmp/sandbox/go/src/pkg/runtime/proc.c:1394
  created by runtime.main
        /tmp/sandbox/go/src/pkg/runtime/proc.c:179
   [process exited with non-zero status]
@rui314
Copy link
Member Author

rui314 commented Mar 19, 2014

Comment 1:

A patch is sent out for review.
https://golang.org/cl/77420044/

@ianlancetaylor
Copy link
Contributor

Comment 2:

This issue was closed by revision 1a21dbc.

Status changed to Fixed.

@rui314 rui314 added the fixed label Mar 19, 2014
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants