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

Clone and Merge panic with nonnullable stdtime types #519

Open
vgough opened this issue Dec 1, 2018 · 3 comments
Open

Clone and Merge panic with nonnullable stdtime types #519

vgough opened this issue Dec 1, 2018 · 3 comments

Comments

@vgough
Copy link

vgough commented Dec 1, 2018

When a message has a non-nullable stdtime type, eg:

    message Test {
        google.protobuf.Timestamp when = 1 [
            (gogoproto.stdtime) = true,
            (gogoproto.nullable) = false
        ];
    }

Then proto.Merge and proto.Clone both panic. Are they trying to reflect walk into the time.Time type even though it's not a proto type?

    panic: merger not found for type:int

    vendor/github.com/gogo/protobuf/proto.(*mergeInfo).computeMergeInfo(0xc0000bb940)
    vendor/github.com/gogo/protobuf/proto/table_merge.go:643 +0xe30
    vendor/github.com/gogo/protobuf/proto.(*mergeInfo).merge(0xc0000bb940, 0xc0000a2d90, 0x1d49910)
    vendor/github.com/gogo/protobuf/proto/table_merge.go:113 +0x4d5
    vendor/github.com/gogo/protobuf/proto.(*mergeInfo).computeMergeInfo.func27(0xc0000a2d90, 0x1d49910)
    vendor/github.com/gogo/protobuf/proto/table_merge.go:536 +0x3e
    vendor/github.com/gogo/protobuf/proto.(*mergeInfo).merge(0xc0000bb900, 0xc0000a2d80, 0x1d49900)
    vendor/github.com/gogo/protobuf/proto/table_merge.go:139 +0x49d
    vendor/github.com/gogo/protobuf/proto.(*mergeInfo).computeMergeInfo.func29(0xc000144528, 0xc0001444a8)
    vendor/github.com/gogo/protobuf/proto/table_merge.go:568 +0x5a
    vendor/github.com/gogo/protobuf/proto.(*mergeInfo).merge(0xc0000bb880, 0xc000144518, 0xc000144498)
    vendor/github.com/gogo/protobuf/proto/table_merge.go:139 +0x49d
    vendor/github.com/gogo/protobuf/proto.(*mergeInfo).computeMergeInfo.func27(0xc000144518, 0xc000144498)
    vendor/github.com/gogo/protobuf/proto/table_merge.go:536 +0x3e
    vendor/github.com/gogo/protobuf/proto.(*mergeInfo).merge(0xc0000bb780, 0xc000144500, 0xc000144480)
    vendor/github.com/gogo/protobuf/proto/table_merge.go:139 +0x49d
    vendor/github.com/gogo/protobuf/proto.(*InternalMessageInfo).Merge(0x1d46f60, 0x182c5e0, 0xc000144500, 0x182c5e0, 0xc000144480)
    vendor/github.com/gogo/protobuf/proto/table_merge.go:50 +0x54
    test.(*Test).XXX_Merge(0xc000144500, 0x182c5e0, 0xc000144480)
    
    vendor/github.com/gogo/protobuf/proto.Merge(0x182c5e0, 0xc000144500, 0x182c5e0, 0xc000144480)
@RaduBerinde
Copy link

I am working on this.

@RaduBerinde
Copy link

Hm, actually, never mind, I think this might be a different issue than repeated non-nullable structs (which is what I'm working on).

@ethanfrey
Copy link

I came across a similar issue.
When I cast the times to UTC before running Clone, all tests passed (no more panic)

t.When = t.When.UTC()

Maybe there is a better solution, but this is the best workaround I could find

ethanfrey added a commit to CosmWasm/cosmos-sdk that referenced this issue Jul 11, 2019
 gogo/protobuf#519
Seems like the old code never properly cloned this, which was not
easily detectable through so many layers of indirection
GiedriusS added a commit to GiedriusS/thanos that referenced this issue Jul 22, 2020
The following panic can be observed when calling `api/v1/rules` without
this change:

```
2020/07/22 21:44:22 http: panic serving 127.0.0.1:49368: merger not found for type:int
goroutine 529 [running]:
net/http.(*conn).serve.func1(0xc00029e640)
        /usr/lib/go-1.14/src/net/http/server.go:1772 +0x139
panic(0x1e0a400, 0xc000368c30)
        /usr/lib/go-1.14/src/runtime/panic.go:975 +0x3e3
github.com/gogo/protobuf/proto.(*mergeInfo).computeMergeInfo(0xc0008b8780)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:662 +0xfc6
github.com/gogo/protobuf/proto.(*mergeInfo).merge(0xc0008b8780, 0xc0007447a0, 0xc00057bb00)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:113 +0x4a2
github.com/gogo/protobuf/proto.(*mergeInfo).computeMergeInfo.func27(0xc000091b70, 0x3991910)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:545 +0x381
github.com/gogo/protobuf/proto.(*mergeInfo).merge(0xc0008b8700, 0xc000091b60, 0x3991900)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:139 +0x46a
github.com/gogo/protobuf/proto.(*mergeInfo).computeMergeInfo.func30(0xc00061e470, 0xc00061e370)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:587 +0x5c
github.com/gogo/protobuf/proto.(*mergeInfo).merge(0xc0008b8340, 0xc00061e460, 0xc00061e360)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:139 +0x46a
github.com/gogo/protobuf/proto.(*mergeInfo).computeMergeInfo.func28(0xc00061e460, 0xc00061e360)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:555 +0x3e
github.com/gogo/protobuf/proto.(*mergeInfo).merge(0xc0008b83c0, 0xc00061e400, 0xc00061e300)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:139 +0x46a
github.com/gogo/protobuf/proto.(*InternalMessageInfo).Merge(0x398a440, 0x2676ea0, 0xc00061e400, 0x2676ea0, 0xc00061e300)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:50 +0x4c
github.com/thanos-io/thanos/pkg/rules/rulespb.(*RecordingRule).XXX_Merge(0xc00061e400, 0x2676ea0, 0xc00061e300)
        /home/gstatkevicius/dev/thanos/pkg/rules/rulespb/rpc.pb.go:527 +0x57
```

Let's use the workaround given here:
gogo/protobuf#519.

Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
GiedriusS added a commit to thanos-io/thanos that referenced this issue Jul 27, 2020
* rules: manager: avoid panic when cloning

The following panic can be observed when calling `api/v1/rules` without
this change:

```
2020/07/22 21:44:22 http: panic serving 127.0.0.1:49368: merger not found for type:int
goroutine 529 [running]:
net/http.(*conn).serve.func1(0xc00029e640)
        /usr/lib/go-1.14/src/net/http/server.go:1772 +0x139
panic(0x1e0a400, 0xc000368c30)
        /usr/lib/go-1.14/src/runtime/panic.go:975 +0x3e3
github.com/gogo/protobuf/proto.(*mergeInfo).computeMergeInfo(0xc0008b8780)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:662 +0xfc6
github.com/gogo/protobuf/proto.(*mergeInfo).merge(0xc0008b8780, 0xc0007447a0, 0xc00057bb00)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:113 +0x4a2
github.com/gogo/protobuf/proto.(*mergeInfo).computeMergeInfo.func27(0xc000091b70, 0x3991910)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:545 +0x381
github.com/gogo/protobuf/proto.(*mergeInfo).merge(0xc0008b8700, 0xc000091b60, 0x3991900)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:139 +0x46a
github.com/gogo/protobuf/proto.(*mergeInfo).computeMergeInfo.func30(0xc00061e470, 0xc00061e370)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:587 +0x5c
github.com/gogo/protobuf/proto.(*mergeInfo).merge(0xc0008b8340, 0xc00061e460, 0xc00061e360)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:139 +0x46a
github.com/gogo/protobuf/proto.(*mergeInfo).computeMergeInfo.func28(0xc00061e460, 0xc00061e360)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:555 +0x3e
github.com/gogo/protobuf/proto.(*mergeInfo).merge(0xc0008b83c0, 0xc00061e400, 0xc00061e300)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:139 +0x46a
github.com/gogo/protobuf/proto.(*InternalMessageInfo).Merge(0x398a440, 0x2676ea0, 0xc00061e400, 0x2676ea0, 0xc00061e300)
        /home/gstatkevicius/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/proto/table_merge.go:50 +0x4c
github.com/thanos-io/thanos/pkg/rules/rulespb.(*RecordingRule).XXX_Merge(0xc00061e400, 0x2676ea0, 0xc00061e300)
        /home/gstatkevicius/dev/thanos/pkg/rules/rulespb/rpc.pb.go:527 +0x57
```

Let's use the workaround given here:
gogo/protobuf#519.

Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>

* rules: manager: cover all cases

Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
justinas added a commit to gravitational/teleport that referenced this issue Feb 1, 2023
justinas added a commit to gravitational/teleport that referenced this issue Feb 3, 2023
* Add Plugin resource schema, methods

* Improve shebang of genproto.sh

Execute using bash, no matter where it actually lives

* Use Metadata.Expiry()

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* Remove field reservations from PluginStatusCode

* Add plugin (un)marshaling

* Snake case fields of Plugin (and children)

* Ensure timestamp fields on Plugin are always UTC

gogo/protobuf#519

* Rename credentials according to proto conventions

* Fold check for nil settings into the type switch

* Remove extraneous field checks

These are set in setStaticFields()

* Add missing godocs

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
justinas added a commit to gravitational/teleport that referenced this issue Feb 23, 2023
* Add Plugin resource schema, methods

* Improve shebang of genproto.sh

Execute using bash, no matter where it actually lives

* Use Metadata.Expiry()

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* Remove field reservations from PluginStatusCode

* Add plugin (un)marshaling

* Snake case fields of Plugin (and children)

* Ensure timestamp fields on Plugin are always UTC

gogo/protobuf#519

* Rename credentials according to proto conventions

* Fold check for nil settings into the type switch

* Remove extraneous field checks

These are set in setStaticFields()

* Add missing godocs

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
justinas added a commit to gravitational/teleport that referenced this issue Feb 23, 2023
* Add Plugin resource schema, methods

* Improve shebang of genproto.sh

Execute using bash, no matter where it actually lives

* Use Metadata.Expiry()



* Remove field reservations from PluginStatusCode

* Add plugin (un)marshaling

* Snake case fields of Plugin (and children)

* Ensure timestamp fields on Plugin are always UTC

gogo/protobuf#519

* Rename credentials according to proto conventions

* Fold check for nil settings into the type switch

* Remove extraneous field checks

These are set in setStaticFields()

* Add missing godocs

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
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

3 participants