protobuf-lua
protobuf-lua copied to clipboard
_FieldSkipper problem
I am trying to parse a Caffe model. I am getting an error related to _FieldSkipper:
/sequoia/data2/kantorov/wigwam_sequoia_gpu101_105/.wigwam/prefix/bin/luajit: ...01_105/.wigwam/prefix/share/lua/5.1/protobuf/decoder.lua:333: attempt to call a nil value
stack traceback:
...01_105/.wigwam/prefix/share/lua/5.1/protobuf/decoder.lua:333: in function 'SkipField'
...pu101_105/.wigwam/prefix/share/lua/5.1/protobuf/init.lua:672: in function '_InternalParse'
...01_105/.wigwam/prefix/share/lua/5.1/protobuf/decoder.lua:248: in function 'field_decoder'
...pu101_105/.wigwam/prefix/share/lua/5.1/protobuf/init.lua:678: in function '_InternalParse'
...01_105/.wigwam/prefix/share/lua/5.1/protobuf/decoder.lua:248: in function 'field_decoder'
...pu101_105/.wigwam/prefix/share/lua/5.1/protobuf/init.lua:678: in function '_internal_parse'
...pu101_105/.wigwam/prefix/share/lua/5.1/protobuf/init.lua:687: in function 'merge_from_string'
...pu101_105/.wigwam/prefix/share/lua/5.1/protobuf/init.lua:696: in function 'ParseFromString'
test.lua:5: in main chunk
[C]: in function 'dofile'
...105/.wigwam/prefix/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
[C]: at 0x00410a40
Putting this code snippet here for convenience:
function _FieldSkipper()
WIRETYPE_TO_SKIPPER = {
_SkipVarint,
_SkipFixed64,
_SkipLengthDelimited,
_SkipGroup,
_EndGroup,
_SkipFixed32,
_RaiseInvalidWireType,
_RaiseInvalidWireType,
}
--wiretype_mask = wire_format.TAG_TYPE_MASK
local ord = string.byte
local sub = string.sub
return function (buffer, pos, pend, tag_bytes)
local wire_type = ord(sub(tag_bytes, 1, 1)) % 8 + 1
--print(wire_type, WIRETYPE_TO_SKIPPER[wire_type])
return WIRETYPE_TO_SKIPPER[wire_type](buffer, pos, pend) --fails here
end
end
I added the print line. It prints: 5 nil
.
I tripped over this today, it's because _SkipGroup
and _EndGroup
aren't actually defined (and hence are nil
). Probably relates to the fact that https://developers.google.com/protocol-buffers/docs/encoding describes wire types 3 and 4 as deprecated.