From 0b39be64c4961037f8c1bd954f565f1081a8424e Mon Sep 17 00:00:00 2001 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> Date: Wed, 14 Aug 2024 21:54:31 +0900 Subject: [PATCH] Fix IsSameObject() Commit 95ed3a5570f1 ("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 :) --- compiler-rt/lib/plsan/plsan_allocator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler-rt/lib/plsan/plsan_allocator.cpp b/compiler-rt/lib/plsan/plsan_allocator.cpp index b94152a73..3786e136c 100644 --- a/compiler-rt/lib/plsan/plsan_allocator.cpp +++ b/compiler-rt/lib/plsan/plsan_allocator.cpp @@ -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(); }