Merged
Conversation
… optimize form value handling
adranwit
approved these changes
Apr 8, 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.
Problem
When running multiple upload in sametime from newui parity test I'm getting concurrent map access issue
Concurrent
multipart/form-datarequests that bind multiplekind=formparameters could crash with a concurrent map write panic inseedFormFromMultipart.Each
Formlocator instance resolves its own parameter viaValue(), which callsseedFormFromMultipartthrough async.Once. However, multipleFormlocator instances share the same*state.Formand*http.Requestfor a given request. When two locators race, the losing goroutine'ssync.Onceis a no-op, but the winning goroutine writes tor.form.Valuesandr.request.Formmaps without holding a lock, causing the panic.A secondary issue existed: calling
form.Set(k, vs...)insideseedFormFromMultipartwould deadlock if the caller already held the form'sRWMutex, becauseSetre-acquires the same lock internally.Root Cause
In
view/state/kind/locator/form.go,seedFormFromMultipart:r.form.Valuesandr.request.Formwas completely unguarded.len(r.request.Form) == 0is false for an already-initialised but empty map, so theurl.Values{}initialisation was sometimes skipped, leading to a nil-map write.Fix
form.Mutex()(sync.RWMutex) before touching any shared map, and defer its unlock.r.form.Values[k]directly instead of callingr.form.Set(), which would attempt to re-lock the same mutex and deadlock.r.request.Form == nilso the initialisation happens exactly when needed, regardless of map length.Changed File
view/state/kind/locator/form.go— 1 file, +10 / −7