x/tools/go/pointer: Pointer MayAlias reports false, when it should report true #46280
Labels
Analysis
Issues related to static analysis (vet, x/tools/go/analysis)
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Did not check, but there were no fixes in the package addressing this issue.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I have the following code (you need https://github.com/uber-go/tally/ ) named
bug.go
in that attachedrepro.zip
, which contains all files needed for reproducing.Scope
is an interface in tally andCounter
function looks like thisThe reason to take the address of
tally.Scope.Counter
inmain
is only to make it appear as if theCounter
function insidetally
is reachable.I have written a pointer analysis driver (
pointsto_bug.go
) (feed the above file to this driver) that is trying to check if the two instances ofs.cm
used insideCounter
atLock()
andUnlock()
"May Alias".The driver collects all values on which the program may be calling
Lock/Unlock/Rlock/RUnlock
to feed to theAnalyze()
function of thepointer
package.Additionally, the two
sync.Mutex
values, on whichLock
andUnlock
are called, are also remembered (inp1
andp2
).Then, in the
Result
provided byAnalyze()
, I query ifp1.MayAlias(p2)
.However, the pointer analysis reports “false”.
What did you expect to see?
The expectation is that the
MayAlias
reporttrue
, in fact here they are the same objects.What did you see instead?
MayAlias
reportsfalse
Addendum
Instead of using the large tally library, if you either create a small
Scope
interface inside themain
package (examplenobug.go
), the function
Counter
is not listed in the set ofssautil.AllFunctions(prog)
. The same holds true if I carve out a small package with just a singleScope
interface and aCounter
function implementation.repro.zip
The text was updated successfully, but these errors were encountered: