Skip to content

Commit

Permalink
Fix IsSameObject()
Browse files Browse the repository at this point in the history
Commit 95ed3a5 ("compiler-rt: Optimize IsSameObject()") introduced
a bug where an object address was wrongly compared with a metadata
address.

The idea behind optimization was based on the assumption that if the
metadata from two different addresses is the same, they must belong to
the same object.

Let's fix it :)
  • Loading branch information
hygoni committed Aug 14, 2024
1 parent 86d632e commit 0b39be6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler-rt/lib/plsan/plsan_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool IsSameObject(Metadata *metadata, const void *x, const void *y) {
if (!metadata || !y)
return false;

return (GetMetadata(y) == x);
return (GetMetadata(y) == metadata);
}

u8 GetRefCount(Metadata *metadata) { return metadata->GetRefCount(); }
Expand Down

0 comments on commit 0b39be6

Please sign in to comment.