Skip to content

Commit

Permalink
llbsolver: take copy of history record to avoid marshal race
Browse files Browse the repository at this point in the history
For active builds these records get stored in the memory
and marshalled on user request. This leads to possibility that
the original record may be updated while the marshalling is
happening, leading to a crash.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
  • Loading branch information
tonistiigi committed Jan 15, 2025
1 parent 78bcf8d commit fafab60
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions solver/llbsolver/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,8 @@ func (h *HistoryQueue) Update(ctx context.Context, e *controlapi.BuildHistoryEve
h.mu.Lock()
defer h.mu.Unlock()

e = e.CloneVT()

if e.Type == controlapi.BuildHistoryEventType_STARTED {
h.active[e.Record.Ref] = e.Record
h.ps.Send(e)
Expand Down

0 comments on commit fafab60

Please sign in to comment.