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

_FieldSkipper problem #8

Open
vadimkantorov opened this issue Oct 16, 2016 · 1 comment
Open

_FieldSkipper problem #8

vadimkantorov opened this issue Oct 16, 2016 · 1 comment

Comments

@vadimkantorov
Copy link

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.

@ijc
Copy link

ijc commented Nov 30, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants