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

Umarshal crashes with "call of reflect.Value.SetMapIndex on zero Value" #27

Closed
dvyukov opened this issue Apr 27, 2015 · 1 comment
Closed

Comments

@dvyukov
Copy link
Member

dvyukov commented Apr 27, 2015

go version devel +87054c4 Wed Apr 22 02:50:48 2015 +0000 linux/amd64
golang/protobuf is on 655cdfa
protoc is on fe7b566

Protobuf is:

syntax = "proto2";

package main;

message M {
  map<int32, int32> f = 1;
}

Program is:

package main

import (
    "github.com/golang/protobuf/proto"
)

func main() {
    m := &M{}
    data := []byte("\v\x00")
    proto.Unmarshal(data, m)
}

Crashes with:

panic: reflect: call of reflect.Value.SetMapIndex on zero Value

goroutine 1 [running]:
runtime.gopanic(0x530860, 0xc2080104e0)
reflect.flag.mustBeExported(0x0)
reflect.Value.SetMapIndex(0x5058e0, 0xc208010440, 0xd5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
github.com/golang/protobuf/proto.(*Buffer).dec_new_map(0xc208052f70, 0xc20806c480, 0xc208010440, 0x0, 0x0)
github.com/golang/protobuf/proto.(*Buffer).unmarshalType(0xc208052f70, 0x7f70a263e198, 0x5384e0, 0xc208048070, 0xc208010400, 0xc208010440, 0x0, 0x0)
github.com/golang/protobuf/proto.(*Buffer).Unmarshal(0xc208052f70, 0x7f70a263e2d8, 0xc208010440, 0x0, 0x0)
github.com/golang/protobuf/proto.UnmarshalMerge(0xc20800a570, 0x2, 0x8, 0x7f70a263e2d8, 0xc208010440, 0x0, 0x0)
github.com/golang/protobuf/proto.Unmarshal(0xc20800a570, 0x2, 0x8, 0x7f70a263e2d8, 0xc208010440, 0x0, 0x0)
main.main()
@dvyukov
Copy link
Member Author

dvyukov commented Apr 27, 2015

/cc @robpike @dsymonds @rsc

linkedincn pushed a commit to linkedin-inc/protobuf that referenced this issue Jul 9, 2015
Previously the code assumed a well-formed map entry,
and would panic in the SetMapIndex call if the map was
missing either the key or value field.

Fixes golang#27.
@golang golang locked as resolved and limited conversation to collaborators Jun 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant