Skip to content

xpath_protobuf input throws: invalid memory address or nil pointer dereference  #14024

Closed
@Nirwx

Description

Relevant telegraf.conf

[agent]
  interval = "5s" 
  metric_batch_size = 5000
  metric_buffer_limit = 30000
  collection_jitter = "0s"
  flush_interval = "5s"
  flush_jitter = "1s"
  precision = ""
  hostname = ""
  omit_hostname = true
  debug = true

[[inputs.file]]
  files = ["/opt/samples/message-3.proto.dump"]
  data_format = "xpath_protobuf"
  xpath_protobuf_file = "sci-message.proto"
  xpath_protobuf_import_paths = [".", "/opt/proto"]
  xpath_protobuf_type = "sci.SciMessage"

[[outputs.file]]
  files = ["/tmp/output.txt"]

Logs from Telegraf

2023-09-29T15:02:49Z I! Loading config: /etc/telegraf/telegraf.conf
2023-09-29T15:02:49Z I! Starting Telegraf 1.26.3
2023-09-29T15:02:49Z I! Available plugins: 235 inputs, 9 aggregators, 27 processors, 22 parsers, 57 outputs, 2 secret-stores
2023-09-29T15:02:49Z I! Loaded inputs: file
2023-09-29T15:02:49Z I! Loaded aggregators: 
2023-09-29T15:02:49Z I! Loaded processors: 
2023-09-29T15:02:49Z I! Loaded secretstores: 
2023-09-29T15:02:49Z I! Loaded outputs: file
2023-09-29T15:02:49Z I! Tags enabled: 
2023-09-29T15:02:49Z I! [agent] Config: Interval:5s, Quiet:false, Hostname:"", Flush Interval:5s
2023-09-29T15:02:49Z D! [agent] Initializing plugins
2023-09-29T15:02:49Z D! [agent] Connecting outputs
2023-09-29T15:02:49Z D! [agent] Attempting connection to [outputs.file]
2023-09-29T15:02:49Z D! [agent] Successfully connected to outputs.file
2023-09-29T15:02:49Z D! [agent] Starting service inputs
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x3cffe24]

goroutine 35 [running]:
github.com/jhump/protoreflect/desc/protoparse.parseToProtoRecursive({0x6764520, 0x400000c708}, {0x4001cdc000, 0x20}, 0x4000cb70e8?, 0x3c9f3a4?, 0x0?)
        /go/pkg/mod/github.com/jhump/protoreflect@v1.15.1/desc/protoparse/parser.go:390 +0x144
github.com/jhump/protoreflect/desc/protoparse.parseToProtoRecursive.func1(0x4000736240, 0x4001cde960, 0x400013fe00, {0x6764520, 0x400000c708}, 0x1d0?, 0x400073e2d0?)
        /go/pkg/mod/github.com/jhump/protoreflect@v1.15.1/desc/protoparse/parser.go:402 +0x16c
github.com/jhump/protoreflect/desc/protoparse.parseToProtoRecursive({0x6764520, 0x400000c708}, {0x4001c1fbc0, 0xc}, 0x4000cb7278?, 0x3c9f3a4?, 0x0?)
        /go/pkg/mod/github.com/jhump/protoreflect@v1.15.1/desc/protoparse/parser.go:403 +0x1d0
github.com/jhump/protoreflect/desc/protoparse.parseToProtoRecursive.func1(0x4000736240, 0x400013fdb0, 0x400013f2c0, {0x6764520, 0x400000c708}, 0xb3?, 0x40001a8319?)
        /go/pkg/mod/github.com/jhump/protoreflect@v1.15.1/desc/protoparse/parser.go:402 +0x16c
github.com/jhump/protoreflect/desc/protoparse.parseToProtoRecursive({0x6764520, 0x400000c708}, {0x400073e2d0, 0xf}, 0x4000cb7408?, 0x3c9f3a4?, 0x0?)
        /go/pkg/mod/github.com/jhump/protoreflect@v1.15.1/desc/protoparse/parser.go:403 +0x1d0
github.com/jhump/protoreflect/desc/protoparse.parseToProtoRecursive.func1(0x4000736240, 0x4000655630, 0x4000654af0, {0x6764520, 0x400000c708}, 0x58a1880?, 0x40004ac301?)
        /go/pkg/mod/github.com/jhump/protoreflect@v1.15.1/desc/protoparse/parser.go:402 +0x16c
github.com/jhump/protoreflect/desc/protoparse.parseToProtoRecursive({0x6764520, 0x400000c708}, {0x40001a8319, 0x11}, 0x400073c100?, 0x0?, 0x400072f5b8?)
        /go/pkg/mod/github.com/jhump/protoreflect@v1.15.1/desc/protoparse/parser.go:403 +0x1d0
github.com/jhump/protoreflect/desc/protoparse.parseToProtosRecursive({0x6764520, 0x400000c708}, {0x4000cb7848, 0x1, 0x0?}, 0x0?, 0x0?)
        /go/pkg/mod/github.com/jhump/protoreflect@v1.15.1/desc/protoparse/parser.go:366 +0x80
github.com/jhump/protoreflect/desc/protoparse.Parser.ParseFiles({{0x40004ac360, 0x2, 0x2}, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...}, ...)
        /go/pkg/mod/github.com/jhump/protoreflect@v1.15.1/desc/protoparse/parser.go:153 +0x194
github.com/influxdata/telegraf/plugins/parsers/xpath.(*protobufDocument).Init(0x400073a120)
        /go/src/github.com/influxdata/telegraf/plugins/parsers/xpath/protocolbuffer_document.go:44 +0xc4
github.com/influxdata/telegraf/plugins/parsers/xpath.(*Parser).Init(0x40006705a0)
        /go/src/github.com/influxdata/telegraf/plugins/parsers/xpath/parser.go:103 +0x5f0
github.com/influxdata/telegraf/models.(*RunningParser).Init(0x67a4710?)
        /go/src/github.com/influxdata/telegraf/models/running_parsers.go:63 +0x3c
github.com/influxdata/telegraf/config.(*Config).addParser(0x40003adce0, {0x5bb58d4, 0x6}, {0x4000a539b0, 0x4}, 0x40004af590)
        /go/src/github.com/influxdata/telegraf/config/config.go:961 +0x4d0
github.com/influxdata/telegraf/config.(*Config).addInput.func1()
        /go/src/github.com/influxdata/telegraf/config/config.go:1174 +0x38
github.com/influxdata/telegraf/plugins/inputs/file.(*File).readMetric(0x40009cdec0, {0x4000752180, 0x21})
        /go/src/github.com/influxdata/telegraf/plugins/inputs/file/file.go:97 +0x288
github.com/influxdata/telegraf/plugins/inputs/file.(*File).Gather(0x40009cdec0, {0x67d8ae0, 0x40001441c0})
        /go/src/github.com/influxdata/telegraf/plugins/inputs/file/file.go:48 +0x90
github.com/influxdata/telegraf/models.(*RunningInput).Gather(0x40004af950, {0x67d8ae0, 0x40001441c0})
        /go/src/github.com/influxdata/telegraf/models/running_input.go:126 +0x54
github.com/influxdata/telegraf/agent.(*Agent).gatherOnce.func1()
        /go/src/github.com/influxdata/telegraf/agent/agent.go:576 +0x30
created by github.com/influxdata/telegraf/agent.(*Agent).gatherOnce
        /go/src/github.com/influxdata/telegraf/agent/agent.go:575 +0xe4

System info

telegraf container version 1.26 to 1.28.1

Docker

FROM telegraf:1.26
COPY telegraf.conf /etc/telegraf/telegraf.conf
COPY proto/base /opt/proto
COPY samples/mqtt_log/dumps /opt/samples
WORKDIR /opt/proto

Steps to reproduce

  1. sudo docker build -t telegraf:test .
  2. sudo docker run -it telegraf:test telegraf

Expected behavior

Protobuf message written to ["/tmp/output.txt"]

Actual behavior

"Invalid Memory Address"

2023-09-29T15:08:04Z D! [agent] Starting service inputs
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x3cffe24]

Additional info

No response

Metadata

Assignees

No one assigned

    Labels

    area/xmlbugunexpected problem or unintended behaviorplugin/parser1. Request for new parser plugins 2. Issues/PRs that are related to parser pluginsupstreambug or issues that rely on dependency fixes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions