Open Bug 1686627 Opened 4 years ago Updated 1 year ago

Pass tsan/coverage compiler flags through to cargo for C code built by cargo

Categories

(Firefox Build System :: General, enhancement)

enhancement

Tracking

(Not tracked)

People

(Reporter: truber, Assigned: truber)

References

Details

We pass cargo only base compiler flags because it can't use different flags for host and target when they are the same machine (https://github.com/rust-lang/cargo/issues/5755). We currently do this for MOZ_ASAN, MOZ_TSAN, MOZ_UBSAN, and MOZ_CODE_COVERAGE. This is at best missing issues by not instrumenting code (ASAN/UBSAN), and at worst could cause false positives (TSAN).

A try build removing these filters is here, with 3 failures: https://treeherder.mozilla.org/jobs?repo=try&revision=c4219053e2cb9cad6d85ba0224a8fd53e4a2e36f

build-linux64-tsan/opt (and build-linux64-tsan-fuzzing/opt):

[webrender 0.61.0] WARNING: ThreadSanitizer: data race (pid=25472)
[webrender 0.61.0]   Read of size 1 at 0x7b0400001812 by thread T6:
[webrender 0.61.0]     #0 memcpy /builds/worker/fetches/llvm-project/llvm/projects/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:808 (build-script-build+0xf502e)
[webrender 0.61.0]     #1 _ZN4core10intrinsics19copy_nonoverlapping17ha9efbb5ae9b4e01dE.llvm.12526265448862221242 :? (build-script-build+0x2c229f)
[webrender 0.61.0]
[webrender 0.61.0]   Previous write of size 1 at 0x7b0400001812 by thread T2:
[webrender 0.61.0]     #0 memcpy /builds/worker/fetches/llvm-project/llvm/projects/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:808 (build-script-build+0xf502e)
[webrender 0.61.0]     #1 _ZN4core10intrinsics19copy_nonoverlapping17ha9efbb5ae9b4e01dE.llvm.12526265448862221242 :? (build-script-build+0x2c229f)
[webrender 0.61.0]
[webrender 0.61.0]   Location is heap block of size 8 at 0x7b0400001810 allocated by thread T2:
[webrender 0.61.0]     #0 malloc /builds/worker/fetches/llvm-project/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:652 (build-script-build+0xe9c5c)
[webrender 0.61.0]     #1 _ZN5alloc5alloc5alloc17ha5d8a14cce03bc63E.llvm.10474360460868876179 :? (build-script-build+0x2c06e4)
[webrender 0.61.0]
[webrender 0.61.0]   Thread T6 (tid=25499, running) created by main thread at:
[webrender 0.61.0]     #0 pthread_create /builds/worker/fetches/llvm-project/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:966 (build-script-build+0xeb44b)
[webrender 0.61.0]     #1 std::sys::unix::thread::Thread::new /rustc/74f7e32f43b5fb0f83896d124566d8242eb786b1//library/std/src/sys/unix/thread.rs:50 (build-script-build+0x311d26)
[webrender 0.61.0]
[webrender 0.61.0]   Thread T2 (tid=25487, running) created by main thread at:
[webrender 0.61.0]     #0 pthread_create /builds/worker/fetches/llvm-project/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:966 (build-script-build+0xeb44b)
[webrender 0.61.0]     #1 std::sys::unix::thread::Thread::new /rustc/74f7e32f43b5fb0f83896d124566d8242eb786b1//library/std/src/sys/unix/thread.rs:50 (build-script-build+0x311d26)
[webrender 0.61.0]
[webrender 0.61.0] SUMMARY: ThreadSanitizer: data race :? in _ZN4core10intrinsics19copy_nonoverlapping17ha9efbb5ae9b4e01dE.llvm.12526265448862221242

build-win64-ccov/opt:

clang: error: no such file or directory: ''@z:/build/workspace/obj-build\code_coverage_cflags'' (only when building crates)

Alexis, can you help investigating these? It could be that this is a host tool being built with TSan where the rust std library is not instrumented?

If this is the case, then I think there is no easy case to solve this (other than cross-compiling all TSan builds) and we should remove the exception for MOZ_ASAN and MOZ_UBSAN only and hope that TSan doesn't cause us any false positives in the future (and potentially address these when they happen).

Flags: needinfo?(a.beingessner)

This was motivated by bug 1685446. :tsmith tested a build with the same patch as above, but with the fix for bug 1685439 reversed.

Before:

AddressSanitizer: SEGV on unknown address

After:

AddressSanitizer: heap-buffer-overflow
Blocks: 1685446
Blocks: 1695285
No longer blocks: 1695285
Depends on: 1695285

Renaming as asan/ubsan are in bug 1695285.

Summary: Pass sanitizer compiler flags through to cargo for C code built by cargo → Pass tsan/coverage compiler flags through to cargo for C code built by cargo
No longer blocks: 1685446
Severity: normal → S3

Clear a needinfo that is pending on an inactive user.

Inactive users most likely will not respond; if the missing information is essential and cannot be collected another way, the bug maybe should be closed as INCOMPLETE.

For more information, please visit BugBot documentation.

Flags: needinfo?(a.beingessner)
You need to log in before you can comment on or make changes to this bug.