Skip to content

Commit 9a56fae

Browse files
committed
[gdb/build] Use -fno-hoist-adjacent-loads for gcc <= 13
When building gdb with gcc 12 and -fsanitize=threads while renabling background dwarf reading by setting dwarf_synchronous to false, I run into: ... (gdb) file amd64-watchpoint-downgrade Reading symbols from amd64-watchpoint-downgrade... (gdb) watch global_var ================== WARNING: ThreadSanitizer: data race (pid=20124) Read of size 8 at 0x7b80000500d8 by main thread: #0 cooked_index_entry::full_name(obstack*, bool) const cooked-index.c:220 zephyrproject-rtos#1 cooked_index::get_main_name(obstack*, language*) const cooked-index.c:735 zephyrproject-rtos#2 cooked_index_worker::wait(cooked_state, bool) cooked-index.c:559 zephyrproject-rtos#3 cooked_index::wait(cooked_state, bool) cooked-index.c:631 zephyrproject-rtos#4 cooked_index_functions::wait(objfile*, bool) cooked-index.h:729 zephyrproject-rtos#5 cooked_index_functions::compute_main_name(objfile*) cooked-index.h:806 zephyrproject-rtos#6 objfile::compute_main_name() symfile-debug.c:461 zephyrproject-rtos#7 find_main_name symtab.c:6503 zephyrproject-rtos#8 main_language() symtab.c:6608 zephyrproject-rtos#9 set_initial_language_callback symfile.c:1634 zephyrproject-rtos#10 get_current_language() language.c:96 ... Previous write of size 8 at 0x7b80000500d8 by thread T1: #0 cooked_index_shard::finalize(parent_map_map const*) \ dwarf2/cooked-index.c:409 zephyrproject-rtos#1 operator() cooked-index.c:663 ... ... SUMMARY: ThreadSanitizer: data race cooked-index.c:220 in \ cooked_index_entry::full_name(obstack*, bool) const ================== Hardware watchpoint 1: global_var (gdb) PASS: gdb.arch/amd64-watchpoint-downgrade.exp: watch global_var ... This was also reported in PR31715. This is due do gcc PR110799 [1], generating wrong code with -fhoist-adjacent-loads, and causing a false positive for -fsanitize=threads. Work around the gcc PR by forcing -fno-hoist-adjacent-loads for gcc <= 13 and -fsanitize=threads. Tested in that same configuration on x86_64-linux. Remaining ThreadSanitizer problems are the ones reported in PR31626 (gdb.rust/dwindex.exp) and PR32247 (gdb.trace/basic-libipa.exp). PR gdb/31715 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31715 Tested-By: Bernd Edlinger <[email protected]> Approved-By: Tom Tromey <[email protected]> [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110799
1 parent 3e0c29b commit 9a56fae

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

gdbsupport/common-defs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
#ifndef COMMON_COMMON_DEFS_H
2121
#define COMMON_COMMON_DEFS_H
2222

23+
#if defined (__SANITIZE_THREAD__) && defined (__GNUC__) \
24+
&& !defined (__clang__) && __GNUC__ <= 13
25+
26+
/* Work around PR gcc/110799. */
27+
#pragma GCC optimize("-fno-hoist-adjacent-loads")
28+
#endif
29+
2330
#include <gdbsupport/config.h>
2431

2532
#undef PACKAGE_NAME

0 commit comments

Comments
 (0)