-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HWasan with external clang runtime (undefined symbol: __hwasan_tls) #129489
Comments
Any advice is welcome |
...we support hwasan? |
with LD_PRELOAD, possible, false-positive $ LD_PRELOAD="/usr/lib/llvm-20/lib/clang/20/lib/linux/libclang_rt.hwasan-aarch64.so" python hello.py
==23210==ERROR: HWAddressSanitizer: tag-mismatch on address 0xffffaf5fc0f0 at pc 0xffffaf4a9070
READ of size 8 at 0xffffaf5fc0f0 tags: c6/00 (ptr/mem) in thread T0
#0 0xffffaf4a9070 in once_cell::sync::OnceCell$LT$T$GT$::get::h74aaba8edb7b3a1e pyo3.663abc5042ebb2ea-cgu.12
#1 0xffffaf48629c in pyo3::gil::GILGuard::assume::h7ab97064da765af1 pyo3.663abc5042ebb2ea-cgu.02
#2 0xffffaf2ae5f8 in pyo3::impl_::trampoline::trampoline::h6bac7f608179330c cryptography_rust.2675ce9b9f5dd535-cgu.08
#3 0xffffaf2cfe38 in PyInit__rust (/src/src/cryptography/hazmat/bindings/_rust.abi3.so+0x2cfe38) (BuildId: d7d9777c073eba735d03135ee9d8c18f82ee7edf)
#4 0x0000006708a0 in _PyImport_LoadDynamicModuleWithSpec /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/importdl.c:169:9
#5 0x00000066fce8 in _imp_create_dynamic_impl /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/import.c:3775:11
#6 0x00000066fce8 in _imp_create_dynamic /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/clinic/import.c.h:506:20
#7 0x000000503b9c in cfunction_vectorcall_FASTCALL /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Objects/methodobject.c:422:24
#8 0x000000567874 in _PyEval_EvalFrameDefault /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/Python/bytecodes.c:3254:26
#9 0x0000004c3b80 in _PyObject_VectorcallTstate /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Include/internal/pycore_call.h:92:11
#10 0x0000004c3b80 in object_vacall /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Objects/call.c:850:14
#11 0x0000004c5764 in PyObject_CallMethodObjArgs /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Objects/call.c:911:24
#12 0x00000058e58c in import_find_and_load /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/import.c:2779:11
#13 0x00000058e58c in PyImport_ImportModuleLevelObject /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/import.c:2862:15
#14 0x000000568764 in import_name /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/ceval.c:2482:15
#15 0x000000568764 in _PyEval_EvalFrameDefault /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/Python/bytecodes.c:2135:19
#16 0x0000005625c0 in _PyEval_EvalFrame /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Include/internal/pycore_ceval.h:89:16
#17 0x0000005625c0 in _PyEval_Vector /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/ceval.c:1683:12
#18 0x0000005625c0 in PyEval_EvalCode /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/ceval.c:578:21
#19 0x00000055f474 in builtin_exec_impl /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/bltinmodule.c:1096:17
#20 0x00000055f474 in builtin_exec /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/clinic/bltinmodule.c.h:586:20
#21 0x000000503888 in cfunction_vectorcall_FASTCALL_KEYWORDS /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Objects/methodobject.c:438:24
#22 0x000000567874 in _PyEval_EvalFrameDefault /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/Python/bytecodes.c:3254:26
#23 0x0000004c3b80 in _PyObject_VectorcallTstate /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Include/internal/pycore_call.h:92:11
#24 0x0000004c3b80 in object_vacall /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Objects/call.c:850:14
#25 0x0000004c5764 in PyObject_CallMethodObjArgs /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Objects/call.c:911:24
#26 0x00000058e58c in import_find_and_load /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/import.c:2779:11
#27 0x00000058e58c in PyImport_ImportModuleLevelObject /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/import.c:2862:15
#28 0x000000568764 in import_name /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/ceval.c:2482:15
#29 0x000000568764 in _PyEval_EvalFrameDefault /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/Python/bytecodes.c:2135:19
#30 0x0000005625c0 in _PyEval_EvalFrame /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Include/internal/pycore_ceval.h:89:16
#31 0x0000005625c0 in _PyEval_Vector /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/ceval.c:1683:12
#32 0x0000005625c0 in PyEval_EvalCode /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/ceval.c:578:21
#33 0x00000055f474 in builtin_exec_impl /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/bltinmodule.c:1096:17
#34 0x00000055f474 in builtin_exec /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/clinic/bltinmodule.c.h:586:20
#35 0x000000503888 in cfunction_vectorcall_FASTCALL_KEYWORDS /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Objects/methodobject.c:438:24
#36 0x000000567874 in _PyEval_EvalFrameDefault /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/Python/bytecodes.c:3254:26
#37 0x0000004c3b80 in _PyObject_VectorcallTstate /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Include/internal/pycore_call.h:92:11
#38 0x0000004c3b80 in object_vacall /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Objects/call.c:850:14
#39 0x0000004c5764 in PyObject_CallMethodObjArgs /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Objects/call.c:911:24
#40 0x00000058e58c in import_find_and_load /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/import.c:2779:11
#41 0x00000058e58c in PyImport_ImportModuleLevelObject /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/import.c:2862:15
#42 0x000000568764 in import_name /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/ceval.c:2482:15
#43 0x000000568764 in _PyEval_EvalFrameDefault /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/Python/bytecodes.c:2135:19
#44 0x0000005625c0 in _PyEval_EvalFrame /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Include/internal/pycore_ceval.h:89:16
#45 0x0000005625c0 in _PyEval_Vector /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/ceval.c:1683:12
#46 0x0000005625c0 in PyEval_EvalCode /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/ceval.c:578:21
#47 0x00000059b860 in run_eval_code_obj /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/pythonrun.c:1722:9
#48 0x00000059b860 in run_mod /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/pythonrun.c:1743:19
#49 0x000000680df0 in pyrun_file /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/pythonrun.c:1643:15
#50 0x0000006809c4 in _PyRun_SimpleFileObject /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/pythonrun.c:433:13
#51 0x000000680790 in _PyRun_AnyFileObject /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Python/pythonrun.c:78:15
#52 0x00000068b7e8 in pymain_run_file_obj /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Modules/main.c:360:15
#53 0x00000068b7e8 in pymain_run_file /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Modules/main.c:379:15
#54 0x00000068b7e8 in pymain_run_python /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Modules/main.c:629:21
#55 0x00000068b7e8 in Py_RunMain /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Modules/main.c:709:5
#56 0x00000068b3a4 in Py_BytesMain /usr/src/python3.12-3.12.3-1ubuntu0.1/build-static/../Modules/main.c:763:12
#57 0xffffb1fd84c0 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#58 0xffffb1fd8594 in __libc_start_main csu/../csu/libc-start.c:360:3
#59 0x0000005f6e6c in _start (/usr/bin/python3.12+0x5f6e6c) (BuildId: 68b2107323bc2433746e01a6b0e473fc32fda806)
Thread: T0 0xeffe00002000 stack: [0xffffc6143000,0xffffc6943000) sz: 8388608 tls: [0xffffb2db1460,0xffffb2db2320)
Memory tags around the buggy address (one tag corresponds to 16 bytes):
0xffffaf5fb800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0xffffaf5fb900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0xffffaf5fba00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0xffffaf5fbb00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0xffffaf5fbc00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0xffffaf5fbd00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0xffffaf5fbe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0xffffaf5fbf00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0xffffaf5fc000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [00]
0xffffaf5fc100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0xffffaf5fc200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0xffffaf5fc300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0xffffaf5fc400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0xffffaf5fc500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0xffffaf5fc600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0xffffaf5fc700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0xffffaf5fc800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Tags for short granules around the buggy address (one tag corresponds to 16 bytes):
0xffffaf5fbf00: .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
=>0xffffaf5fc000: .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. [..]
0xffffaf5fc100: .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
See https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html#short-granules for a description of short granule tags
Registers where the failure occurred (pc 0xffffaf4a9070):
x0 c600ffffaf5fc0f0 x1 0000ffffb2d948a0 x2 0000ffffb07826c8 x3 0000ffffb07798f0
x4 0000000000079830 x5 0000000000b2d8d0 x6 e100ef3dffe3d838 x7 0000ffffaf604b18
x8 00000000000000c6 x9 0000000000000000 x10 0000000000000000 x11 0000000000000000
x12 0000ffffc693fbb0 x13 0200effeffffffff x14 00000ffffc693fc3 x15 0000000000000000
x16 0000ffffb222d064 x17 0000000000000007 x18 0000000000000006 x19 3100ffffc693fbb0
x20 0200efff00000000 x21 1000ffffc693fcb0 x22 00401dffc0000011 x23 0000ffffc693fc30
x24 0200efff00000000 x25 0000ffffc693fc10 x26 00401dffc0000091 x27 00401dffc00000d1
x28 0000000000b8a278 x29 0000ffffc693fc50 x30 0000ffffaf4a9074 sp 0000ffffc693fb80
SUMMARY: HWAddressSanitizer: tag-mismatch pyo3.663abc5042ebb2ea-cgu.12 in once_cell::sync::OnceCell$LT$T$GT$::get::h74aaba8edb7b3a1e |
We've experimental support for it for some targets (see #123615 (comment)), but I don't know if it we currently support cross-language hardware-assisted AddressSanitizer. Unfortunately, I don't have the hardware to reproduce this issue at hand at the moment, but if it hasn't been tried yet, I'd suggest trying matching the same LLVM version and runtimes version across languages, and proper LTO (i.e., |
Hi. I want to build with HWAsan and join c / rust / python code. I prepared example based on a public project https://github.com/pyca/cryptography
Steps to repro
config.toml
Dockerfile
hello.py
hello.py
Setup cryptography
config.toml
Create
config.toml
with content:Dockerfile
Create
Dockerfile
with content:Create
hello.py
(from examples) with content:Build
Run with pip isolation (by default):
We can see that ENVs and
/.cargo/config.toml
are ignored and a lot of HWasan errors showed. I dont know how to fix it correctly (it is problem one; possibly, question to python community).Run without pip isolation (but it is unreal to do in real world application):
Run
hello.py
We can see that ENVs and
/.cargo/config.toml
are not ignored, but__hwasan_tls
(it is problem #2).Additional information
Few things which helps me it other cases:
disable link-time-optimisation (otherwise link fails with R_AARCH64_ADR_PREL_PG_HI21 out of range)
use only
lld
as linker (otherwise link fails R_AARCH64_ADR_PREL_PG_HI21 out of range)use shared (otherwise ASan conflicts or link fails)
use external clang runtime (otherwise ASan conflicts)
do not use gcc (sometimes it timeouts)
pass target-feature=+tagged-globals (otherwise R_AARCH64_ADR_PREL_PG_HI21 out of range)
pass -mllvm -hwasan-globals=0 (otherwise FP crashes)
use global cargo config with environment variables (in case env-only, args do not passed to cargo/rustc)(pip isolation)The text was updated successfully, but these errors were encountered: