Repository navigation
http: fix resolver cache nil race - #6791
Merged
Merged
Conversation
Signed-off-by: Bryce Gibson <bgibson@limepoint.com>
Signed-off-by: Bryce Gibson <bgibson@limepoint.com>
Avoid storing typed nil HTTP metadata in the resolver cache after failed metadata resolution. Also make resolver cache release functions consistently callable when no error is returned. Add a client integration test covering concurrent same-URL HTTP sources with and without checksum when the server returns 401. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Contributor
|
Thanks! 🙏 |
There was a problem hiding this comment.
Pull request overview
This PR addresses a crash in BuildKit’s HTTP source resolver-cache interaction by preventing nil/invalid cache values and ensuring cache lock release behavior is safe, plus adding an integration test to reproduce the original SIGSEGV scenario.
Changes:
- Avoid storing/propagating
nilresolver-cache entries from the HTTP source handler and improve invalid-cache-value diagnostics. - Make
resolverCache.Lock()return a safe no-op release function when the key disappears, and harden combined cache locking againstnilreleasers. - Add an integration test that reproduces the 401 + checksum/no-checksum concurrency scenario.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
source/http/source.go |
Avoids caching nil resolved values and validates resolver-cache entries more defensively in HTTP snapshot/metadata paths. |
solver/resolvercache.go |
Prevents nil release function returns (key-deleted case) and avoids appending nil releasers in combined cache aggregation. |
client/client_test.go |
Adds an integration test to exercise the prior crash scenario (401 responses with concurrent HTTP sources sharing resolver-cache key). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
868
to
871
| v2, ok := v.(*metadataWithRef) | ||
| if !ok { | ||
| return nil, errors.Errorf("invalid HTTP resolver cache value: %T", vals[0]) | ||
| if !ok || v2 == nil { | ||
| return nil, errors.Errorf("invalid HTTP resolver cache value: %T", v) | ||
| } |
Member
There was a problem hiding this comment.
This copilot review looks legit.
4 tasks done
crazy-max
reviewed
May 28, 2026
|
|
||
| var requests atomic.Int32 | ||
| server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| if requests.Add(1) == 1 { |
Member
There was a problem hiding this comment.
Can we reset the counter per iteration so each solve forces one request to wait while the other arrives?
Move the HTTP snapshot resolver-cache lookup into a helper so the lock release is deferred after acquisition. This keeps invalid cache entries and digest mismatch errors from returning while the cache lock is held. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Use the resolver-cache ref ID directly when loading a cached HTTP snapshot. This avoids dereferencing missing metadata for cache entries found during a concurrent solve. Reset the unauthorized checksum race request counter per solve iteration so each retry applies the intended first-request delay. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
crazy-max
approved these changes
Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6788
Carry #6790