Skip to content

Commit 3db2fa9

Browse files
committed
No longer print incorrect stack traces
1 parent 5dd38d7 commit 3db2fa9

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

compiler-rt/lib/tysan/tysan.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,9 @@ __tysan_instrument_mem_inst(char *dest, char *src, uint64_t size,
281281
}
282282
}
283283

284-
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
285-
__tysan_check(void *addr, int size, tysan_type_descriptor *td, int flags) {
286-
GET_CALLER_PC_BP_SP;
287-
284+
ALWAYS_INLINE
285+
static void __tysan_check_internal(void *addr, int size, tysan_type_descriptor *td, int flags,
286+
uptr pc, uptr bp, uptr sp) {
288287
bool IsRead = flags & 1;
289288
bool IsWrite = flags & 2;
290289
const char *AccessStr;
@@ -327,6 +326,12 @@ __tysan_check(void *addr, int size, tysan_type_descriptor *td, int flags) {
327326
}
328327
}
329328

329+
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
330+
__tysan_check(void *addr, int size, tysan_type_descriptor *td, int flags) {
331+
GET_CALLER_PC_BP_SP;
332+
__tysan_check_internal(addr, size, td, flags, pc, bp, sp);
333+
}
334+
330335
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
331336
__tysan_instrument_with_shadow_update(void *ptr, tysan_type_descriptor *td,
332337
bool sanitizeFunction,
@@ -347,18 +352,22 @@ __tysan_instrument_with_shadow_update(void *ptr, tysan_type_descriptor *td,
347352
// We're about to set the type. Make sure that all bytes in the value
348353
// are also of unknown type.
349354
bool isAllUnknownTD = GetNotAllUnkTD((uint64_t)shadowData, accessSize);
350-
if (isAllUnknownTD)
351-
__tysan_check(ptr, accessSize, td, flags);
355+
if (isAllUnknownTD) {
356+
GET_CALLER_PC_BP_SP;
357+
__tysan_check_internal(ptr, accessSize, td, flags, pc, bp, sp);
358+
}
352359
SetShadowType(td, shadowData, accessSize);
353360
} else {
354-
__tysan_check(ptr, accessSize, td, flags);
361+
GET_CALLER_PC_BP_SP;
362+
__tysan_check_internal(ptr, accessSize, td, flags, pc, bp, sp);
355363
}
356364
} else {
357365
// We appear to have the right type. Make sure that all other bytes in
358366
// the type are still marked as interior bytes. If not, call the runtime.
359367
bool isNotAllBadTD = GetNotAllBadTD((uint64_t)shadowData, accessSize);
360368
if (isNotAllBadTD) {
361-
__tysan_check(ptr, accessSize, td, flags);
369+
GET_CALLER_PC_BP_SP;
370+
__tysan_check_internal(ptr, accessSize, td, flags, pc, bp, sp);
362371
}
363372
}
364373
} else if (shadowIsNull) {

0 commit comments

Comments
 (0)