Skip to content

Use of unsafe not easily diagnosed #428

Open
@adg

Description

@adg

Something about the proto3 marshaling code throws an exception in the generated code. I have put together this small reproduction of the issue: gopherjs-fail.zip

It throws this error (and stack trace):

gopherjs-fail.js:33783 Uncaught TypeError: structPointer_StringVal(...).$get is not a function
$packages.github.com/gogo/protobuf/proto.Buffer.ptr.enc_ref_string @ gopherjs-fail.js:33783method.
$expr @ gopherjs-fail.js:70
$packages.github.com/gogo/protobuf/proto.Buffer.ptr.enc_struct @ gopherjs-fail.js:33490
$packages.github.com/gogo/protobuf/proto.Buffer.ptr.Marshal @ gopherjs-fail.js:32260
$packages.github.com/gogo/protobuf/proto.Marshal @ gopherjs-fail.js:32188
$packages.gopherjs-fail.main @ gopherjs-fail.js:113711
$packages.gopherjs-fail.$init @ gopherjs-fail.js:113723
fun @ gopherjs-fail.js:1465
$goroutine @ gopherjs-fail.js:1463
$runScheduled @ gopherjs-fail.js:1504

Here's the code around line 33783:

    Buffer.ptr.prototype.enc_ref_string = function(p, base) {
        var $ptr, base, o, p, v;
        o = this;
        v = structPointer_StringVal(base, p.field).$get();   // <-- throws the exception
        o.buf = $appendSlice(o.buf, p.tagcode);
        o.EncodeStringBytes(v);
        return $ifaceNil;
    };

Not sure where to begin debugging this. 😦

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions