Skip to content

Commit

Permalink
Fix segmentation fault in Ingester.LabelValues response marshaling (#…
Browse files Browse the repository at this point in the history
…8003)

* Copy label values out of mmapped region before returning from RPC handler.

* comment touchup

* Add changelog message.

* Update CHANGELOG.md

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

---------

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
  • Loading branch information
seizethedave and aknuds1 committed Apr 30, 2024
1 parent daefa2f commit 2455c30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* [BUGFIX] Distributor: fix down scaling of native histograms in the distributor when timeseries unmarshal cache is in use. #7947
* [BUGFIX] Distributor: fix cardinality API to return more accurate number of in-memory series when number of zones is larger than replication factor. #7984
* [BUGFIX] All: fix config validation for non-ingester modules, when ingester's ring is configured with spread-minimizing token generation strategy. #7990
* [BUGFIX] Ingester: copy LabelValues strings out of mapped memory to avoid a segmentation fault if the region becomes unmapped before the result is marshaled. #8003

### Mixin

Expand Down
7 changes: 7 additions & 0 deletions pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,13 @@ func (i *Ingester) LabelValues(ctx context.Context, req *client.LabelValuesReque
return nil, err
}

// The label value strings are sometimes pointing to memory mapped file
// regions that may become unmapped anytime after Querier.Close is called.
// So we copy those strings.
for i, s := range vals {
vals[i] = strings.Clone(s)
}

return &client.LabelValuesResponse{
LabelValues: vals,
}, nil
Expand Down

0 comments on commit 2455c30

Please sign in to comment.