Skip to content

Commit 78926b4

Browse files
Apply Victor's suggestions
Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 7b1be6e commit 78926b4

5 files changed

Lines changed: 22 additions & 10 deletions

File tree

‎Doc/using/configure.rst‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,8 +1022,11 @@ Debug options
10221022
<https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html#supported-architectures>`_,
10231023
which only tags heap allocations and is unsafe for programs that ``fork()``,
10241024
including much of the test suite.
1025+
See the `LLVM HWASan design documentation
1026+
<https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html>`_
1027+
for more information.
10251028

1026-
.. versionadded:: 3.16
1029+
.. versionadded:: next
10271030

10281031
.. option:: --with-memory-sanitizer
10291032

‎Lib/test/libregrtest/utils.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,9 @@ def get_build_info():
402402

403403
# --with-address-sanitizer
404404
sanitizers = []
405-
if support.check_sanitizer(address=True):
405+
if support.check_sanitizer(hwaddress=True):
406+
sanitizers.append("HWASAN")
407+
elif support.check_sanitizer(address=True):
406408
sanitizers.append("ASAN")
407409
# --with-memory-sanitizer
408410
if support.check_sanitizer(memory=True):

‎Lib/test/support/__init__.py‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,11 +448,12 @@ def skip_if_buildbot(reason=None):
448448
isbuildbot = False
449449
return unittest.skipIf(isbuildbot, reason)
450450

451-
def check_sanitizer(*, address=False, memory=False, ub=False, thread=False,
452-
function=True):
451+
def check_sanitizer(*, address=False, hwaddress=False, memory=False, ub=False,
452+
thread=False, function=True):
453453
"""Returns True if Python is compiled with sanitizer support"""
454-
if not (address or memory or ub or thread):
455-
raise ValueError('At least one of address, memory, ub or thread must be True')
454+
if not (address or hwaddress or memory or ub or thread):
455+
raise ValueError('At least one of address, hwaddress, memory, ub or '
456+
'thread must be True')
456457

457458

458459
cflags = sysconfig.get_config_var('CFLAGS') or ''
@@ -461,11 +462,14 @@ def check_sanitizer(*, address=False, memory=False, ub=False, thread=False,
461462
'-fsanitize=memory' in cflags or
462463
'--with-memory-sanitizer' in config_args
463464
)
465+
hwaddress_sanitizer = (
466+
'-fsanitize=hwaddress' in cflags or
467+
'--with-hwaddress-sanitizer' in config_args
468+
)
464469
address_sanitizer = (
465470
'-fsanitize=address' in cflags or
466-
'-fsanitize=hwaddress' in cflags or
467471
'--with-address-sanitizer' in config_args or
468-
'--with-hwaddress-sanitizer' in config_args
472+
hwaddress_sanitizer
469473
)
470474
ub_sanitizer = (
471475
'-fsanitize=undefined' in cflags or
@@ -481,6 +485,7 @@ def check_sanitizer(*, address=False, memory=False, ub=False, thread=False,
481485
return (
482486
(memory and memory_sanitizer) or
483487
(address and address_sanitizer) or
488+
(hwaddress and hwaddress_sanitizer) or
484489
(ub and ub_sanitizer) or
485490
(thread and thread_sanitizer) or
486491
(function and function_sanitizer)

‎configure‎

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎configure.ac‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3544,7 +3544,8 @@ AC_ARG_WITH(
35443544
AC_MSG_RESULT([$withval])
35453545
hwasan_flags="-fsanitize=hwaddress"
35463546
# x86-64 lacks address tagging, so HWASan needs the page aliasing mode there.
3547-
# See https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html#supported-architectures
3547+
# See gh-156049 and
3548+
# https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html#supported-architectures
35483549
AS_CASE([$host_cpu],
35493550
[x86_64|amd64], [hwasan_flags="$hwasan_flags -fsanitize-hwaddress-experimental-aliasing"]
35503551
)

0 commit comments

Comments
 (0)