• Jan Mercl's avatar
    go/token: Fix race in FileSet.PositionFor. · 52fcff3e
    Jan Mercl authored
    Methods of FileSet are documented to be safe for concurrent use by
    multiple goroutines, so FileSet is protected by a mutex and all its
    methods use it to prevent concurrent mutations. All methods of File that
    mutate the respective FileSet, including AddLine, do also lock its
    mutex, but that does not help when PositionFor is invoked concurrently
    and reads without synchronization what AddLine mutates.
    
    The change adds acquiring a RLock around the racy call of File.position
    and the respective test.
    
    Fixes #16548
    
    Change-Id: Iecaaa02630b2532cb29ab555376633ee862315dd
    Reviewed-on: https://go-review.googlesource.com/25345Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    52fcff3e
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...