224 Commits

Author SHA1 Message Date
Eisuke Kawashima
0af6c304e4
[NFC][compiler-rt] fix(compiler-rt/**.py): fix comparison to None (#94015)
from PEP8
(https://peps.python.org/pep-0008/#programming-recommendations):

> Comparisons to singletons like None should always be done with is or
is not, never the equality operators.
2024-10-24 07:32:10 -07:00
Vitaly Buka
bbccc521c6
[lsan] Disable test with barriers on Darwin (#112810) 2024-10-17 19:23:08 -07:00
Vitaly Buka
fa81868fe6
[lsan] Log thread history (#111949)
Only with high verbosity and leak reports, or thread logging requested.
2024-10-11 18:09:37 -07:00
Vitaly Buka
e1cff8bf81
[lsan] Add debug option to "deflake" leaks (#112037)
There are hard to debug leaks which look like
false.

In general, repeating leak checking should not
affect set of leaks significantly, especial
`at_exit` leak checking.

But if we see significant discrepancy, it may give
us a clue for investigation.
2024-10-11 16:57:19 -07:00
Vitaly Buka
6b67f79f5f [lsan] Deflake test on aarch64
Looks like registers are clobbered by sched_yield.
2024-09-07 14:44:04 -07:00
rjmansfield
e51fc36c38
[lsan][test] Allow testcase to execute on remote targets without not utility (#87350) 2024-08-29 15:06:33 -07:00
Michael Kruse
a35ac42fac
[compiler-rt] Revise IDE folder structure (#89753)
Update the folder titles for targets in the monorepository that have not
seen taken care of for some time. These are the folders that targets are
organized in Visual Studio and XCode
(`set_property(TARGET <target> PROPERTY FOLDER "<title>")`)
when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically
deduce the folder. This reduces the number of
`set_property`/`set_target_property`, but are still necessary when
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's
root CMakeLists.txt.
2024-06-04 09:26:45 +02:00
Vitaly Buka
090edd376e [lsan] Disable symbolization in test
With internal symbolizer leaking pointers can be
copied into alive memory used by symbolizer.
2024-03-13 17:28:32 -07:00
Vitaly Buka
4ff2f60f1f [test][LSAN] Check if HWASAN is availibe before testing
OSX fails to compiler with -fsanitize=hwaddress.

Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=1486833
2023-09-27 11:13:06 -07:00
Vitaly Buka
058e9b0374
[test] Don't check COMPILER_RT_STANDALONE_BUILD for deps (#66259)
COMPILER_RT_STANDALONE_BUILD is only needed to be
checked for dependencies outside of compiler-rt.
2023-09-15 12:29:59 -07:00
Artem Dergachev
0a3519d5a2 [LSan] Mark create_thread_leak.cpp as UNSUPPORTED: darwin.
It started to fail in a flaky manner a few days ago on GreenDragon buildbots
(i.e. x86_64-darwin). I didn't track down the root cause but LSan isn't
actually supported on darwin anyway, so UNSUPPORTED seems appropriate.

Prior art: 3ff080b5.
2023-08-31 16:41:35 -07:00
Vitaly Buka
23d1b6577a [test][sanitizer] Prepare test for Internal Symbolizer
Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D157946
2023-08-15 13:42:01 -07:00
Kirill Stoimenov
51e49e12e7 [HWASAN][LSAN] Replace cstdint with stdint.h
Reviewed By: brooksmoses, MaskRay

Differential Revision: https://reviews.llvm.org/D155994
2023-07-21 22:20:12 +00:00
Kirill Stoimenov
0365ccd2a1 [HWASAN][LSAN] Fix false positive memory leak reports on X86_64
Before this patch when running HWASAN on x86_64 with with memory tagging support we got a bunch of false memory leak reports. The reason for that is that the heuristic used to detect if an 8 bytes could be a user pointer was not valid when memory tagging is used as the top byte could contain non-zero information.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D155338
2023-07-18 19:04:30 +00:00
Leonard Grey
55a2c4eb04 [lsan] Remove use_tls=0 from a few tests
The Objective-C runtime now stashes some state in TLS so any
test that indirectly initializes an Objective-C object will
have false positive leaks unless use_tls=1 as is the default.

Differential Revision: https://reviews.llvm.org/D153081
2023-06-20 18:52:11 -04:00
Tobias Hieta
f98ee40f4b
[NFC][Py Reformat] Reformat python files in the rest of the dirs
This is an ongoing series of commits that are reformatting our
Python code. This catches the last of the python files to
reformat. Since they where so few I bunched them together.

Reformatting is done with `black`.

If you end up having problems merging this commit because you
have made changes to a python file, the best way to handle that
is to run git checkout --ours <yourfile> and then reformat it
with black.

If you run into any problems, post to discourse about it and
we will try to help.

RFC Thread below:

https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

Reviewed By: jhenderson, #libc, Mordante, sivachandra

Differential Revision: https://reviews.llvm.org/D150784
2023-05-25 11:17:05 +02:00
Vitaly Buka
3cabfe666c [LSAN] Use ThreadArgRetval in LSAN
Fixes false leaks on thread retval.

Reviewed By: thurston

Differential Revision: https://reviews.llvm.org/D150165
2023-05-18 01:11:54 -07:00
Vitaly Buka
6d74cdc7c4 [ASAN] Use ThreadArgRetval in ASAN
Fixes false leaks on thread retval.

Reviewed By: thurston

Differential Revision: https://reviews.llvm.org/D150106
2023-05-18 01:09:37 -07:00
Vitaly Buka
dcd4c3c3fd Revert "[ASAN] Use ThreadArgRetval in ASAN"
https://bugs.chromium.org/p/chromium/issues/detail?id=1445676

This reverts commit 1030bd181eb74b67b7ea51631ce4becca410c406.
2023-05-16 10:49:45 -07:00
Vitaly Buka
d2b434b4e9 Revert "[LSAN] Use ThreadArgRetval in LSAN"
https://bugs.chromium.org/p/chromium/issues/detail?id=1445676

This reverts commit 20a3c6e84e0955ac20762c35e8c2435017ae967d.
2023-05-16 10:49:45 -07:00
Vitaly Buka
20a3c6e84e [LSAN] Use ThreadArgRetval in LSAN
Fixes false leaks on thread retval.

Reviewed By: thurston

Differential Revision: https://reviews.llvm.org/D150165
2023-05-11 15:58:04 -07:00
Vitaly Buka
1030bd181e [ASAN] Use ThreadArgRetval in ASAN
Fixes false leaks on thread retval.

Reviewed By: thurston

Differential Revision: https://reviews.llvm.org/D150106
2023-05-11 15:51:40 -07:00
Vitaly Buka
68b76af8a4 [HWSAN] Use ThreadArgRetval in HWSAN
Fixes false leaks on thread arg, retval.

Reviewed By: Enna1

Differential Revision: https://reviews.llvm.org/D150166
2023-05-11 15:20:02 -07:00
Vitaly Buka
b617dc4c3a [test][lsan] Don't recompile the test 2023-05-08 00:43:04 -07:00
Vitaly Buka
d9908116bc [test][sanitizer] Improve test expectation
Now we can fix sanitizers for the test one by one.
2023-05-08 00:35:07 -07:00
Vitaly Buka
c3a46fe9c1 [test][lsan] Remove std::vector from test 2023-05-05 14:48:57 -07:00
Vitaly Buka
43de9cbec9 [test][lsan] For thread args/result leak 2023-05-05 14:48:13 -07:00
zhanglimin
fd9f7b9010 [lsan][test] Obtaining page size using sysconf(_SC_PAGESIZE)
The effectiveness of the mprotect function depends on whether
the first argument is aligned to a page boundary. If mprotect
doesn't work, the kernel will not generate a SIGSEGV signal for
the process when the calling process tries to access memory in
a manner that violates the protection. If so, this test fails.

The problem for this test is that it uses a fixed 4 kB page size
and is aligned. This fails when the page size is not 4 kB. For
example, this fails on LoongArch which uses a 16 kB pagesize.

Reviewed By: SixWeining, xen0n, MaskRay, vitalybuka

Differential Revision: https://reviews.llvm.org/D148407
2023-04-24 14:27:41 +08:00
Vitaly Buka
e6191923f5 [NFC][lsan] Rename test function 2023-04-18 12:47:23 -07:00
Vitaly Buka
1e1d1b1b5a [lsan] Disabled D148281 test on Darwin
For unknown reason it fails to link.
2023-04-18 12:47:23 -07:00
Vitaly Buka
7760272778 [lsan] Don't crash on ThreadRegistry::threads_ data race
Comment "No lock needed" in CurrentThreadContext was wrong.
Concurent ThreadRegistry::CreateThread can resize and relocate
ThreadRegistry::threads_ the same time CurrentThreadContext reads it.

To mitigate lock cost we store ThreadContext* instead of tid in
THREADLOCAL cache, we can tid from the ThreadContext*.

Reviewed By: kstoimenov, MaskRay

Differential Revision: https://reviews.llvm.org/D148281
2023-04-17 15:33:43 -07:00
Vitaly Buka
3712dd73a1 [test][lsan] Reset pointer to leak memory 2023-04-11 15:37:35 -07:00
Vitaly Buka
7849967ecc [lsan] Regression test for 7d328668691a 2023-04-11 15:35:11 -07:00
Kirill Stoimenov
d917da66c8 [HWASAN] Fix test which was failing with tag mismatch due to missing no_sanitize statement 2023-04-04 19:42:27 +00:00
Vitaly Buka
329cb1d3f4 [lsan] Fix Asan/Hwasan testing conditions 2023-04-03 20:01:43 -07:00
Kirill Stoimenov
5c1aabde67 [LSAN] Make sure HWASAN tests are linked with lld
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D144289
2023-02-22 19:40:59 +00:00
Kirill Stoimenov
d87468e56c [HWASAN] Add support for max_allocation_size_mb option
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D143667
2023-02-09 20:24:47 +00:00
Kirill Stoimenov
c9258ab7f2 [LSAN] Fix pthread_create interceptor to ignore leaks in real pthread_create.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D143209
2023-02-08 22:55:19 +00:00
Kirill Stoimenov
550cb763da Revert "[LSAN] Fix pthread_create interceptor to ignore leaks in real pthread_create."
This reverts commit a7db3cb257ff6396481f44427bccd0ca5abf4d63.
2023-02-08 21:55:55 +00:00
Kirill Stoimenov
a7db3cb257 [LSAN] Fix pthread_create interceptor to ignore leaks in real pthread_create.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D143209
2023-02-08 20:36:35 +00:00
Kirill Stoimenov
914f86949a [HWASAN] Fix Metadata::IsAllocatedMetadata::IsAllocated to return true even if the requested size is 0.
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D143438
2023-02-06 23:47:23 +00:00
Kirill Stoimenov
b2aa0a4650 [LSAN] Enable more tests which are passing as is in HWASAN.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D143126
2023-02-02 18:06:35 +00:00
Kirill Stoimenov
042f01b289 Revert "[LSAN] Enable more tests which are passing as is in HWASAN."
This reverts commit b4abbf17572dce3993402f2e00e72678518ef6e1.
2023-02-02 17:12:31 +00:00
Kirill Stoimenov
b4abbf1757 [LSAN] Enable more tests which are passing as is in HWASAN.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D143126
2023-02-02 16:39:26 +00:00
Kirill Stoimenov
029b410df3 [HWASAN] Set os_id in Thread::Init to make sure that the thread can be found by GetThreadByOsIDLocked.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D143125
2023-02-02 01:42:48 +00:00
Kirill Stoimenov
eb3be66028 [LSAN] Add GetUserAddr function which returns the user visible address of an internal pointer
For HWASAN this would be the tagged address. It is the same pointer when pointer tagging is not used. Coincidently this also fixes some test which rely on comparing pointers.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D143121
2023-02-02 00:39:00 +00:00
Kirill Stoimenov
49b081c827 [LSAN] Enable some tests which are passing as is in HWASAN.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D143114
2023-02-01 23:21:30 +00:00
Fangrui Song
ea7695dcca [hwasan] Support __lsan_default_options
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D142938
2023-01-30 15:07:46 -08:00
Kirill Stoimenov
3301f6e135 [LSAN][HWASAN] Run LSAN tests with HWASAN enabled
A lot of tests are disabled by using UNSUPPORTED. The plan is to remove UNSUPPORTED for tests that are fixed.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D142676
2023-01-30 22:32:31 +00:00
Hans Wennborg
3b9606b5cb Revert "[LSAN][HWASAN] Run LSAN tests with HWASAN enabled"
This broke the sanitizer tests on Mac, see e.g.
https://green.lab.llvm.org/green/job/clang-stage1-RA/32739/ and comment on the
code review.

> A lot of tests are disabled by using UNSUPPORTED. The plan is to remove UNSUPPORTED for tests that are fixed.
>
> Reviewed By: vitalybuka
>
> Differential Revision: https://reviews.llvm.org/D142676

This reverts commit f9a01630988716f1b52afe6727f34fe86c07c58a.
and follow-up commit bf47ffaa76fbda1ba96d41ee2681e45d2445be1e
(https://reviews.llvm.org/D142812).
2023-01-30 20:57:16 +01:00