From fafab6074c26b0aad09ebaf46868dd36dd3957bf Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Wed, 15 Jan 2025 10:54:54 -0800 Subject: [PATCH] llbsolver: take copy of history record to avoid marshal race 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 --- solver/llbsolver/history.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/solver/llbsolver/history.go b/solver/llbsolver/history.go index 04e83cfbdd9f..1e2c6e3f64eb 100644 --- a/solver/llbsolver/history.go +++ b/solver/llbsolver/history.go @@ -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)