elastic / beats

:tropical_fish: Beats - Lightweight shippers for Elasticsearch & Logstash
https://www.elastic.co/products/beats
Other
103 stars 4.92k forks source link

[metricbeat][panw] fix concurrent map write error caused by reusing a mapstr.M #40901

Closed tommyers-elastic closed 1 month ago

tommyers-elastic commented 1 month ago

In the existing code, we create a mapstr.M containing attributes to set in the RootFields of metric events, which is reused several times in a loop. In the publisher code, the root fields are modified, e.g. https://github.com/elastic/beats/blob/main/metricbeat/mb/event.go#L79, which causes a panic due to fatal error: concurrent map iteration and map write, as the same mapstr.M object is still being used in later iterations of the loop.

Proposed commit message

Checklist

Disruptive User Impact

Author's Checklist

How to test this PR locally

Related issues

-

Use cases

Screenshots

Logs

botelastic[bot] commented 1 month ago

This pull request doesn't have a Team:<team> label.