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

Validate being called on structs that are nil #144

Closed
blakerouse opened this issue Jan 29, 2020 · 0 comments · Fixed by #145
Closed

Validate being called on structs that are nil #144

blakerouse opened this issue Jan 29, 2020 · 0 comments · Fixed by #145
Assignees
Labels

Comments

@blakerouse
Copy link
Contributor

In the case that the reflect.Value is nil even if it implements the Validator interface Validate should not be called. Before 0.8.0 Validate would not be called, causing issues with existing beats and libbeat.

One example of an error in libbeat:

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0x43c8945]

goroutine 44 [running]:
testing.tRunner.func1(0xc00016e500)
        /usr/local/go/src/testing/testing.go:874 +0x3a3
panic(0x451d380, 0x4a41c80)
        /usr/local/go/src/runtime/panic.go:679 +0x1b2
github.com/elastic/beats/libbeat/common/transport/tlscommon.(*CertificateConfig).Validate(...)
        /Users/blake/Code/elastic/beats/src/github.com/elastic/beats/libbeat/common/transport/tlscommon/types.go:256
github.com/elastic/beats/libbeat/common/transport/tlscommon.(*Config).Validate(0x0, 0x4522fa0, 0x0)
        /Users/blake/Code/elastic/beats/src/github.com/elastic/beats/libbeat/common/transport/tlscommon/config.go:97 +0x5
github.com/elastic/beats/vendor/github.com/elastic/go-ucfg.tryValidate(0x4522fa0, 0xc00046a290, 0x196, 0x4522fa0, 0xc00046a290)
        /Users/blake/Code/elastic/beats/src/github.com/elastic/beats/vendor/github.com/elastic/go-ucfg/validator.go:123 +0xf3
github.com/elastic/beats/vendor/github.com/elastic/go-ucfg.tryRecursiveValidate(0x4522fa0, 0xc00046a290, 0x196, 0xc00016c400, 0x0, 0x0, 0x0, 0x0, 0x0)
        /Users/blake/Code/elastic/beats/src/github.com/elastic/beats/vendor/github.com/elastic/go-ucfg/validator.go:163 +0x132
github.com/elastic/beats/vendor/github.com/elastic/go-ucfg.reifyGetField(0xc00015a900, 0xc00016c400, 0x0, 0x0, 0x0, 0x0, 0x44ade00, 0x3, 0x4522fa0, 0xc00046a290, ...)
        /Users/blake/Code/elastic/beats/src/github.com/elastic/beats/vendor/github.com/elastic/go-ucfg/reify.go:317 +0x19a
github.com/elastic/beats/vendor/github.com/elastic/go-ucfg.reifyStruct(0xc00016c400, 0x4594f00, 0xc00046a1b0, 0x199, 0xc00015a900, 0x0, 0x0)
        /Users/blake/Code/elastic/beats/src/github.com/elastic/beats/vendor/github.com/elastic/go-ucfg/reify.go:282 +0x939
github.com/elastic/beats/vendor/github.com/elastic/go-ucfg.reifyInto(0xc00016c400, 0x44df7a0, 0xc00046a1b0, 0x16, 0xc00015a900, 0x0, 0x4594f00)
        /Users/blake/Code/elastic/beats/src/github.com/elastic/beats/vendor/github.com/elastic/go-ucfg/reify.go:172 +0x3fb
github.com/elastic/beats/vendor/github.com/elastic/go-ucfg.(*Config).Unpack(0xc00015a900, 0x44df7a0, 0xc00046a1b0, 0x4a4ea60, 0x3, 0x3, 0x24, 0xc000064e90)
        /Users/blake/Code/elastic/beats/src/github.com/elastic/beats/vendor/github.com/elastic/go-ucfg/reify.go:155 +0x103
github.com/elastic/beats/libbeat/common.(*Config).Unpack(...)
        /Users/blake/Code/elastic/beats/src/github.com/elastic/beats/libbeat/common/config.go:168
github.com/elastic/beats/libbeat/outputs/logstash.readConfig(0xc00015a900, 0x45be607, 0x8, 0x45bd0f3, 0x3, 0x0, 0x0, 0x45bd108, 0x3, 0x0, ...)
        /Users/blake/Code/elastic/beats/src/github.com/elastic/beats/libbeat/outputs/logstash/config.go:78 +0x171
github.com/elastic/beats/libbeat/outputs/logstash.TestConfig.func1(0xc00016e500)
        /Users/blake/Code/elastic/beats/src/github.com/elastic/beats/libbeat/outputs/logstash/config_test.go:90 +0x89
testing.tRunner(0xc00016e500, 0xc00046a120)
        /usr/local/go/src/testing/testing.go:909 +0xc9
created by testing.(*T).Run
        /usr/local/go/src/testing/testing.go:960 +0x350
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants