Skip to content

map value limited to 255 bytes ? #772

@adg

Description

@adg
The following code will cause a panic when executed:

--

package main
 
import "fmt"
 
type Test struct {
    A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W []string
}
 
var TestMap map[string]Test
 
func main() {
    TestMap = make(map[string]Test)
    fmt.Println("You won't see me")
}
 
--

throw: assert

panic PC=0xb7f98fec
throw+0x46 /usr/local/devel/chroot-pakiety/go/src/src/pkg/runtime/runtime.c:73
    throw(0xffffffff, 0x808dcc8)
hash_init+0x8c /usr/local/devel/chroot-pakiety/go/src/src/pkg/runtime/hashmap.c:147
    hash_init(0x808dcc8, 0x0, 0xb7f99018, 0xb7f99014, 0x0, ...)
makemap+0x110 /usr/local/devel/chroot-pakiety/go/src/src/pkg/runtime/hashmap.c:698
    makemap(0xb7fd2460, 0x11c, 0x8049157, 0x804918a)
runtime.makemap+0x36 /usr/local/devel/chroot-
pakiety/go/src/src/pkg/runtime/hashmap.c:738
    runtime.makemap(0x808e938, 0x807a014, 0x0, 0x0, 0x8048833, ...)
main.main+0x33 /home/tvCzyo/prog.go:12
    main.main()
mainstart+0xf /usr/local/devel/chroot-pakiety/go/src/src/pkg/runtime/386/asm.s:83
    mainstart()
goexit /usr/local/devel/chroot-pakiety/go/src/src/pkg/runtime/proc.c:145
    goexit()

--

This appears to be because the size of a Test instance is greater than the max size of a
map 
value. We should either support larger values in a map, or give a more informative error
message.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions