19657 Commits

Author SHA1 Message Date
Hans Wennborg
05e31438ac Revert "[compiler-rt] Remove %T from shared object substitutions (#155302)"
This broke a bunch of Mac lit tests, see comment on the PR.

This reverts commit bbd48fbb2fadebd8597e9cce6e318e9d07809783.
2025-09-08 10:00:13 +02:00
Aiden Grossman
bbd48fbb2f Reapply "[compiler-rt] Remove %T from shared object substitutions (#155302)"
This reverts commit 36ca6748bc9150f8c56df6ba15deb118ff700e4a.

This broke a couple Android buildbots, theoretically due to different
directory structure that has now been addressed.
2025-09-06 22:41:10 +00:00
Thurston Dang
69c777bf3d
Revert "[compiler-rt][sanitizer-common] adding C23 memset_explicit interception." (#157317)
Reverts llvm/llvm-project#154428 due to buildbot breakages (e.g.,
https://lab.llvm.org/buildbot/#/builders/51/builds/22984)
2025-09-06 14:57:45 -07:00
David CARLIER
7e55a4c993
[compiler-rt][sanitizer-common] adding C23 memset_explicit interception. (#154428) 2025-09-06 21:48:16 +01:00
David CARLIER
d949ac6796
[compiler-rt] openat2 syscall interception. (#153846) 2025-09-06 02:30:02 +01:00
Roland McGrath
5cf4959b21
[scudo] Move getPageSize() decl to common.h header (#157146)
The getPageSize() function is defined in the platform-specific
source files but used in common.cpp.  Every function used across
files should be declared in a header so the same declaration is
in scope for the callers and the definition.
2025-09-05 11:48:38 -07:00
Vitaly Buka
e1c463bc1e
Revert "[UBSan] [min-rt] make minimal runtime handlers weak" (#156975)
Existing `__ubsan_report_error` should be enough to solve this.

Ability to override on two levels, may result in hard to debug bugs
when in the same binary strong __ubsan_report_error and
__ubsan_handle_##name##_minimal_abort
 defined in unrelated components.

With one entry point we will have at least linking error.

Reverts llvm/llvm-project#154220
2025-09-04 22:30:02 +00:00
bernhardu
d349daa135
[win/asan] Improve SharedReAlloc with HEAP_REALLOC_IN_PLACE_ONLY. (#132558)
Currently with HEAP_REALLOC_IN_PLACE_ONLY a new allocation
gets returned with the content copied from the original pointer,
which gets freed.

But applications may rely on HEAP_REALLOC_IN_PLACE_ONLY returning
the same pointer as they give as input to e.g. RtlReAllocateHeap.
If e.g. growing is not possible it fails without
modifying the input pointer.

Downside of this patch is, it won't detect accesses to the area
getting "free" by a shrinking reallocation.
2025-09-03 16:34:55 -07:00
Fei Peng
6bbf0c30ca
[sanitizer] Fix prctl interceptor causing PAC authentication failure (#153081)
The root cause of this crash is that prctl(PR_PAC_RESET_KEYS) generates
a new PAC key. As a result, paciasp and autiasp use different keys,
leading to the crash.

The solution is: if prctl's option is PR_PAC_RESET_KEYS, call real_prctl
directly. This is implemented in assembly, so there are no PAC
instructions involved.

Related issue: https://github.com/android/ndk/issues/1848

```
0000000000095468 <__interceptor_prctl>:
   95468: d503233f     	paciasp
   9546c: d10183ff     	sub	sp, sp, #0x60
   95470: a90267fe     	stp	x30, x25, [sp, #0x20]
   95474: a9035ff8     	stp	x24, x23, [sp, #0x30]
   95478: a90457f6     	stp	x22, x21, [sp, #0x40]
   9547c: a9054ff4     	stp	x20, x19, [sp, #0x50]
   95480: aa1e03f4     	mov	x20, x30
   95484: aa0403f3     	mov	x19, x4
   95488: aa0303f6     	mov	x22, x3
   9548c: aa0203f7     	mov	x23, x2
   95490: aa0103f5     	mov	x21, x1
   95494: 2a0003f8     	mov	w24, w0
   95498: 940172ec     	bl	0xf2048 <_ZN6__tsan10cur_threadEv>
   9549c: 4f05e540     	movi	v0.16b, #0xaa
   954a0: 52801548     	mov	w8, #0xaa               // =170
   954a4: aa1403fe     	mov	x30, x20
   954a8: 39007fe8     	strb	w8, [sp, #0x1f]
   954ac: aa0003f4     	mov	x20, x0
   954b0: 910043e0     	add	x0, sp, #0x10
   954b4: aa1403e1     	mov	x1, x20
   954b8: bc01b3e0     	stur	s0, [sp, #0x1b]
   954bc: d50320ff     	xpaclri
   954c0: aa1e03e3     	mov	x3, x30
   954c4: 97ffb461     	bl	0x82648 <_ZN6__tsan17ScopedInterceptorC2EPNS_11ThreadStateEPKcm>
   954c8: 97ff75ea     	bl	0x72c70 <_ZN11__sanitizer10StackTrace12GetCurrentPcEv>
   954cc: 394c2688     	ldrb	w8, [x20, #0x309]
   954d0: 7100051f     	cmp	w8, #0x1
   954d4: 540000c1     	b.ne	0x954ec <__interceptor_prctl+0x84>
   954d8: b9400a88     	ldr	w8, [x20, #0x8]
   954dc: 35000088     	cbnz	w8, 0x954ec <__interceptor_prctl+0x84>
   954e0: 394c2288     	ldrb	w8, [x20, #0x308]
   954e4: 7100051f     	cmp	w8, #0x1
   954e8: 54000501     	b.ne	0x95588 <__interceptor_prctl+0x120>
   954ec: f0001128     	adrp	x8, 0x2bc000 <_ZN6__tsanL23interceptor_placeholderE+0xcac0>
   954f0: 2a1803e0     	mov	w0, w24
   954f4: aa1503e1     	mov	x1, x21
   954f8: f9452508     	ldr	x8, [x8, #0xa48]
   954fc: aa1703e2     	mov	x2, x23
   95500: aa1603e3     	mov	x3, x22
   95504: aa1303e4     	mov	x4, x19
   95508: d63f0100     	blr	x8
   9550c: f9400bf3     	ldr	x19, [sp, #0x10]
   95510: 394c2668     	ldrb	w8, [x19, #0x309]
   95514: 7100051f     	cmp	w8, #0x1
   95518: 540002a1     	b.ne	0x9556c <__interceptor_prctl+0x104>
   9551c: 39406be8     	ldrb	w8, [sp, #0x1a]
   95520: 7100051f     	cmp	w8, #0x1
   95524: 54000d60     	b.eq	0x956d0 <__interceptor_prctl+0x268>
   95528: 394067e8     	ldrb	w8, [sp, #0x19]
   9552c: 7100051f     	cmp	w8, #0x1
   95530: 54000de0     	b.eq	0x956ec <__interceptor_prctl+0x284>
   95534: b9400a68     	ldr	w8, [x19, #0x8]
   95538: 350001a8     	cbnz	w8, 0x9556c <__interceptor_prctl+0x104>
   9553c: b9403268     	ldr	w8, [x19, #0x30]
   95540: 35000e48     	cbnz	w8, 0x95708 <__interceptor_prctl+0x2a0>
   95544: f9400e68     	ldr	x8, [x19, #0x18]
   95548: 91002109     	add	x9, x8, #0x8
   9554c: f27c1d3f     	tst	x9, #0xff0
   95550: 54000ec0     	b.eq	0x95728 <__interceptor_prctl+0x2c0>
   95554: 5280004a     	mov	w10, #0x2               // =2
   95558: f900010a     	str	x10, [x8]
   9555c: f9000e69     	str	x9, [x19, #0x18]
   95560: f9400a68     	ldr	x8, [x19, #0x10]
   95564: d1002108     	sub	x8, x8, #0x8
   95568: f9000a68     	str	x8, [x19, #0x10]
   9556c: a9454ff4     	ldp	x20, x19, [sp, #0x50]
   95570: a94457f6     	ldp	x22, x21, [sp, #0x40]
   95574: a9435ff8     	ldp	x24, x23, [sp, #0x30]
   95578: a94267fe     	ldp	x30, x25, [sp, #0x20]
   9557c: 910183ff     	add	sp, sp, #0x60
   95580: d50323bf     	autiasp
   95584: d65f03c0     	ret
   ...
```
2025-09-03 15:41:53 +02:00
Thurston Dang
51163c5dbd
[msan] Change zero_alloc.cpp testcase to use stdlib.h (#156491)
Avoid build breakage on Mac
2025-09-02 12:48:37 -07:00
Thurston Dang
e2a8b9862c
[asan] Change zero_alloc.cpp testcase to use stdlib.h, re-enable on Mac (#156490)
Avoid build breakage on Mac (reported at
https://github.com/llvm/llvm-project/pull/155943#issuecomment-3244593484)
2025-09-02 12:48:31 -07:00
Hans Wennborg
a6bd36eb71 Mark asan/TestCases/zero_alloc.cpp unsupported on Mac for now
It's failing due to the malloc.h include, see comment on
https://github.com/llvm/llvm-project/pull/155943
2025-09-02 11:46:04 +02:00
Brad Smith
27c80fba53
[sanitizer_common] Older Haiku needs _GNU_SOURCE (#156291)
Co-authored-by: Jérôme Duval <jerome.duval@gmail.com>
2025-09-01 06:06:50 -04:00
Thurston Dang
6dfd8d0ab4
[asan] Rewrite Windows/heaprealloc_alloc_zero check to avoid dereference (#156211)
The test currently checks that 1-byte is allocated when malloc(0) is
called, by dereferencing the pointer.
https://github.com/llvm/llvm-project/pull/155943 changed ASan to
consider the dereference to be a heap buffer overflow. This patch
changes the test to check the allocated size is still 1-byte, but not
dereference the pointer.

This aims to fix the breakage reported in
https://github.com/llvm/llvm-project/pull/155943#issuecomment-3239543505

It also enables the test for 64-bit Windows.
2025-08-30 15:43:51 -07:00
dong jianqiang
e68d66a1af
[compiler-rt] Make __EH_FRAME_LIST__ const to avoid RW .eh_frame mapping (#155764) (#155955)
In crtbegin.c, `__EH_FRAME_LIST__` was previously declared as a writable
array of pointers. This caused the linker to place .eh_frame into a
segment with read-write permissions, leading to larger virtual memory
footprint at runtime (e.g. .eh_frame mapped into both LOAD and RELRO).

Changing it to `static void * const __EH_FRAME_LIST__[]` ensures that
the section is treated as read-only, matching GCC’s behavior with
`__EH_FRAME_BEGIN__`. This prevents unnecessary RW mappings of .eh_frame
while preserving the intended semantics.

Fixes: #155764
2025-08-30 14:56:44 +08:00
Thurston Dang
e317c7e36f [fuzzer] Fix-forward fix-forward CrossOverTest.cpp
https://github.com/llvm/llvm-project/pull/156103 was missing the return
value
2025-08-29 21:28:33 +00:00
Thurston Dang
f9c6c95df0
[fuzzer] Avoid buffer overflow in CrossOverTest.cpp (and fix-forward build breakage from #155943) (#156103)
ASan now detects dereferences of zero-sized allocations
(https://github.com/llvm/llvm-project/pull/155943; the corresponding
MSan change is https://github.com/llvm/llvm-project/pull/155944). This
appears to have detected a bug in CrossOverTest.cpp, causing a buildbot
breakage. This patch fixes the test.

Buildbot report: https://lab.llvm.org/buildbot/#/builders/4/builds/8732
```
            7: ==949882==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf169cfbe0010 at pc 0xb5f45efc6d1c bp 0xffffd933e460 sp 0xffffd933e458
check:20'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            8: READ of size 1 at 0xf169cfbe0010 thread T0
check:20'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            9:  #0 0xb5f45efc6d18 in LLVMFuzzerTestOneInput /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/compiler-rt/test/fuzzer/CrossOverTest.cpp:48:7
check:20'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:20'1                                                                                                                                 ?                             possible intended match
           10:  #1 0xb5f45eec7288 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:619:13
check:20'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           11:  #2 0xb5f45eec85d4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:812:3
check:20'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           12:  #3 0xb5f45eec8c60 in fuzzer::Fuzzer::Loop(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:872:3
check:20'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           13:  #4 0xb5f45eeb5c64 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:923:6
check:20'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           14:  #5 0xb5f45eee09d0 in main /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
check:20'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

For context, FuzzerLoop.cpp:812 tries empty input:
```
810  // Test the callback with empty input and never try it again.
811  uint8_t dummy = 0;
812  ExecuteCallback(&dummy, 0);
```
2025-08-29 14:01:06 -07:00
Chris Apple
8f317c1a37
[rtsan] Add versioned pthread_cond interceptors (#155970)
This fixes #146120, confirmed by the original reporter

Previously reviewed as #155181, but re-submitting for better
book-keeping.


Adds versioned pthread_cond interceptors, and the
pthread_cond_init/_destroy interceptors
2025-08-29 11:06:31 -07:00
Thurston Dang
b3452d90b0
[asan] Detect dereferencing zero-alloc as heap buffer overflow (#155943)
When a zero-byte allocation is requested, ASan actually allocates 1-byte
for compatibility. This change poisons that byte, to detect
dereferences.

Also updates the test from #155933
2025-08-29 10:19:47 -07:00
Thurston Dang
8784dcef34
[msan] Detect dereferencing zero-alloc as use-of-uninitialized-value (#155944)
When a zero-byte allocation is requested, MSan actually allocates 1-byte
for compatibility. This change poisons that byte, to detect
dereferences.

Also updates the test from #155934
2025-08-29 10:19:38 -07:00
Chris Apple
d25452694b
Revert "[rtsan] Support legacy pthread_cond variables (#152947)" (#155963)
This reverts commit aa4bc2ed914bd08feb90ba691bd50482e8de51eb.

As discussed on #155181 , this introduced some unneeded code. Reverting
and applying the smaller version of the fix
2025-08-28 19:33:43 -07:00
Thurston Dang
e502768dbc
[asan] Add test for deferencing zero-sized malloc/calloc (#155933)
ASan fails to catch this, because 0-byte allocations are converted into
1-byte allocations.

Bug originally reported by dvyukov
2025-08-28 15:48:52 -07:00
Thurston Dang
7450a00ae4
[msan] Add test for deferencing zero-sized malloc/calloc (#155934)
MSan fails to catch this, because 0-byte allocations are converted into
1-byte allocations.
    
Bug originally reported by dvyukov
2025-08-28 15:48:31 -07:00
Rageking8
a89a66e69d
[docs][NFC] Resolve mismatched backticks (#155883)
Fix various backtick mismatches.

NFC.
2025-08-28 23:55:30 +02:00
Brad Smith
2eaba46f46
compiler-rt: Use OpenBSD's elf_aux_info to detect AArch64 HW features (#155768) 2025-08-28 13:58:47 -04:00
gbMattN
492089e097
Provide ErrorBadParamsToCopyContiguousContainerAnnotations a more cor… (#139870)
…rect 'reason' when constructing ErrorBase

Co-authored-by: Tacet <advenam.tacet@gmail.com>
2025-08-28 17:21:55 +01:00
Brad Smith
7b3745ed0c
[builtins] Rename freebsd to elf_aux_info to reflect the function called. NFCI (#155749) 2025-08-28 02:49:59 -04:00
Aiden Grossman
36ca6748bc Revert "Reapply "[compiler-rt] Remove %T from shared object substitutions (#155302)""
This reverts commit 7624197dacfde71d21e3c88c308696ebb6f49f94.

This is causing more buildbot failures that probably need some offline
investigation:
1. https://lab.llvm.org/buildbot/#/builders/186/builds/11923
2025-08-26 23:54:00 +00:00
PiJoules
316004764f
[fuzzer][Fuchsia] Forward fix for undefined StartRssThread (#155514)
The declaration was static when it shouldn't be since it can be defined
in FuzzerUtilFuchsia.cpp
2025-08-26 16:08:54 -07:00
Aiden Grossman
7624197dac Reapply "[compiler-rt] Remove %T from shared object substitutions (#155302)"
This reverts commit 1d3c302171692293f74f92236b446b9240774d4d.

There were three test failures:
odr-violation.cpp - Attempted to fix by keeping everything in the same
folder.
interception-in-shared-lib-test.cpp - Tried folding comments to preserve
line numberings. Almost seems like a debug info issue on PPC.
odr_c_test.c - Attempted to fix by keeping everything in the same
folder.
2025-08-26 21:56:03 +00:00
Vitaly Buka
a997d45af9 [NFC][Asan] Remove volatile from test
After #155447.
It's not needed, but does not compile on PowerPC.
2025-08-26 14:50:00 -07:00
Vitaly Buka
5953e07c8c
[NFC][Asan] Fix warning in test (#155447)
After #150028.

Warning:
```
asan_test.cpp:398:27: error: allocation of insufficient size '0' for type 'int' with size '4'
```
2025-08-26 18:03:59 +00:00
Kazu Hirata
79566b2e83 [compiler-rt] Fix a warning
This patch fixes:

  compiler-rt/lib/asan/tests/asan_test.cpp:398:27: error: allocation
  of insufficient size '0' for type 'int' with size '4'
  [-Werror,-Walloc-size]
2025-08-26 10:33:53 -07:00
Fabio D'Urso
c05567842b
[GWP-ASan] Include <unistd.h> for sysconf(_SC_PAGESIZE) (#155261)
This fixes build failures on Fuchsia that started with #153860
2025-08-26 15:11:48 +02:00
Aiden Grossman
1d3c302171 Revert "[compiler-rt] Remove %T from shared object substitutions (#155302)"
This reverts commit 769155912787941edd32f91ef9acd7493ba64f14.

This took out at least three buildbots. Reverting until I can figure out what
is going on.
2025-08-25 23:02:44 +00:00
Aiden Grossman
7691559127
[compiler-rt] Remove %T from shared object substitutions (#155302)
Given we are trying to deprecate %T and remove it, we also need to
remove it from the substitutions within compiler-rt. This is the last
remaining upstream user.

This slightly increases the complexity of using these substitutions
because now you need to create/cd into a %t.dir (specifically named
that) at the beginning of the directory, but I'm not sure that's more
knowledge than what was needed before to write a test using this
substitution. These tests also definitely were not race safe previously.
2025-08-25 14:55:28 -07:00
Joel Sing
5886a276ed
[tsan][riscv] correct Go race detector mapping for RISC-V sv48 VMA (#154700)
The executable and heap range for RISC-V sv48 VMA is supposed to end at
0xe000000000, rather than 0x0e00000000 as currently configured.
2025-08-25 11:16:21 -07:00
Joel Sing
9958b1c908
[tsan][riscv] add Go race detector support for RISC-V sv39 VMA (#154701)
The majority of readily available RISC-V hardware provides sv39, rather
than
sv48. Add a memory mapping for sv39, which will allow the Go race
detector
to be used on more hardware.
2025-08-25 11:13:43 -07:00
PiJoules
7153392a10
Reapply "[fuzzer][Fuchsia] Prevent deadlock from suspending threads" … (#155271)
…(#155042)

This reverts commit 781a4db6b50bb660cb293d3e7e29957aeb4b02ac.

Relanded with the fix declaring StartRssThread.
2025-08-25 09:50:42 -07:00
Alex Rønne Petersen
5abec20b25
[compiler-rt] Remove leftovers of FreeBSD md5/sha2 interceptors (#153351)
This code was added in 18a7ebda99044473fdbce6376993714ff54e6690, but was
not properly reverted in d0b9c2c5647656738cda3fb670aa5d3b3a69d784.

Removing this code makes it possible to cross-compile TSan for FreeBSD
with `zig cc` which does not provide libcrypt when cross-compiling.

I also removed a `term.h` include (ncurses) which appeared to be
unnecessary and likewise prevented cross-compilation with `zig cc` from
working.
2025-08-24 23:52:08 +02:00
Alex Rønne Petersen
9ec771bd4a
[compiler-rt] Avoid depending on the libnvmm header for NetBSD (#153534)
Use the system headers instead since we don't actually need anything
from libnvmm; we only care about ioctls and related structures.

This makes it possible to cross-compile TSan for NetBSD with `zig cc`
which does not provide libnvmm when cross-compiling.

I also removed a `term.h` include (ncurses) which appeared to be
unnecessary and likewise prevented cross-compilation with `zig cc` from
working.
2025-08-24 20:39:34 +02:00
Chris Apple
aa4bc2ed91
[rtsan] Support legacy pthread_cond variables (#152947)
fixes #146120 

Follows a pattern put forward in tsan:

71ffa2a4d3/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp (L1366-L1371)


71ffa2a4d3/compiler-rt/lib/tsan/dd/dd_interceptors.cpp (L204-L208)

To properly deal with memory corruption on older versions of
pthread_cond variables.
2025-08-23 11:46:32 -07:00
gulfemsavrun
781a4db6b5
Revert "[fuzzer][Fuchsia] Prevent deadlock from suspending threads" (#155042)
Reverts llvm/llvm-project#154854 because it broke Clang toolchain
builders for Fuchsia:

https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8705803649235662417/overview
2025-08-22 15:54:46 -07:00
PiJoules
b9987503d2
[fuzzer][Fuchsia] Prevent deadlock from suspending threads (#154854)
Every once in a couple hundred runs of a downstream fuzzer test, we see
a fuzzing test freeze while waiting for a thread to be suspended. The
main thread is frozen because it's waiting to suspend either the alarm
or rss thread which is stuck waiting for an exception they sent out to
be handled. Specifically, both threads send out a synthetic
`ZX_EXCP_THREAD_STARTING` exception to be handled by the crash handling
thread which sets up an exception channel on the whole process with
`ZX_EXCEPTION_CHANNEL_DEBUGGER`. This is the only channel type that
listens to thread stop/start exceptions. Normally, the exception would
be ignored and the alarm or rss thread would continue normally once the
crash handling thread closes the read exception. However, the memory
snapshot machinery can suspend this thread while its in the process of
waiting for or handling a `ZX_EXCP_THREAD_STARTING` sent by either the
rss or alarm thread. If this is suspended first, then we attempt to
suspend either the alarm or rss thread while they're still waiting for
the crash handling thread to handle its exception, we will freeze
waiting for those threads to give the suspend signal, which they won't
because they're blocked on waiting for the exception handler. This is
the deadlock.

Until there's a way for the memory snapshot machinery to suspend the
thread while it's stuck on an exception, then we can work around this in
the meantime by just ensuring the alarm and rss threads start normally
via signals on the initial startup path. I can assert locally the
freezing doesn't occur after 6000 runs where prior we would see it every
couple hundred runs. Note this type of issue can arise again if the
fuzzing test launches any dangling threads that happen to not start yet.
One of the recommendations for writing a fuzz test is that the test may
launch threads, but they should be joined by the end of the test
(https://llvm.org/docs/LibFuzzer.html#fuzz-target), so hopefully we
won't see this type of bug rise frequently from fuzz tests. More
broadly, this can also arise if any process launches its own debugger
via `ZX_EXCEPTION_CHANNEL_DEBUGGER`, but I would think in practice this
isn't very likely to happen.

More context in https://fxbug.dev/436923423.

---------

Co-authored-by: Petr Hosek <phosek@google.com>
2025-08-22 20:22:32 +00:00
davidtrevelyan
0368e76fde
[rtsan] Fix ioctl args in interceptor test (#154959) 2025-08-22 21:04:47 +01:00
Aiden Grossman
0f07235e5f
[Asan] Make fuse-lld-globals.cpp require lld (#155010)
Otherwise if we do not build lld, this test will run and fail. Found
when experimenting with LLVM_ENABLE_RUNTIMES="compiler-rt" on Windows.
2025-08-22 12:20:14 -07:00
Mariusz Borsa
839d0aa881
[Sanitizers][Test] XFAIL fuzzer-ubsan on darwin arm (#154860)
This test currently fails to compile on darwin arm host
(green.lab.llvm.org)

rdar://158303001

Co-authored-by: Mariusz Borsa <m_borsa@apple.com>
2025-08-22 10:54:48 -07:00
Amit Kumar Pandey
3e3e362648
Reapply "[compiler-rt]: fix CodeQL format-string warnings via explicit (#154937)
casts (#153843)"

Error Fixes.

> Replace ssize_t with sanitizer equivalent ssize.

This reverts commit ee5367bedb97ae8df9930ac1c162b3287c743663.
2025-08-22 18:35:29 +05:30
Hans Wennborg
ee5367bedb Revert "[compiler-rt]: fix CodeQL format-string warnings via explicit casts (#153843)"
It broke the build:

compiler-rt/lib/hwasan/hwasan_thread.cpp:177:11: error: unknown type name 'ssize_t'; did you mean 'size_t'?
   177 |          (ssize_t)unique_id_, (void *)this, (void *)stack_bottom(),
       |           ^~~~~~~
       |           size_t

> This change addresses CodeQL format-string warnings across multiple
> sanitizer libraries by adding explicit casts to ensure that printf-style
> format specifiers match the actual argument types.
>
> Key updates:
> - Cast pointer arguments to (void*) when used with %p.
> - Use appropriate integer types and specifiers (e.g., size_t -> %zu,
> ssize_t -> %zd) to avoid mismatches.
> - Fix format specifier mismatches across xray, memprof, lsan, hwasan,
> dfsan.
>
> These changes are no-ops at runtime but improve type safety, silence
> static analysis warnings, and reduce the risk of UB in variadic calls.

This reverts commit d3d5751a39452327690b4e011a23de8327f02e86.
2025-08-22 12:50:53 +02:00
Hans Wennborg
8bf105cb01
[asan] Build the Windows runtime with /hotpatch (#154694)
Win/ASan relies on the runtime's functions being 16-byte aligned so it
can intercept them with hotpatching. This used to be true (but not
guaranteed) until #149444.

Passing /hotpatch will give us enough alignment and generally ensure
that the functions are hotpatchable.
2025-08-22 10:40:04 +02:00