)]}'
{
  "commit": "33fd0a33639897e1c3403389de882cadd344a494",
  "tree": "21f90b5cd1e9e799143e9b24439e14a63e1abe7a",
  "parents": [
    "47226049bb7cdbc93543db13e6305c0091f4f642"
  ],
  "author": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Sat Jul 02 13:03:34 2022 +0200"
  },
  "committer": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Sat Jul 02 13:03:34 2022 +0200"
  },
  "message": "[gdb/symtab] Fix data race on per_cu-\u003edwarf_version\n\nWhen building gdb with -fsanitize\u003dthread and gcc 12, and running test-case\ngdb.dwarf2/dwz.exp, we run into a data race between thread T2 and the main\nthread in the same write:\n...\nWrite of size 1 at 0x7b200000300c:^M\n    #0 cutu_reader::cutu_reader(dwarf2_per_cu_data*, dwarf2_per_objfile*, \\\n    abbrev_table*, dwarf2_cu*, bool, abbrev_cache*) gdb/dwarf2/read.c:6252 \\\n    (gdb+0x82f3b3)^M\n...\nwhich is here:\n...\n         this_cu-\u003edwarf_version \u003d cu-\u003eheader.version;\n...\n\nBoth writes are called from the parallel for in dwarf2_build_psymtabs_hard,\nthis one directly:\n...\n    #1 process_psymtab_comp_unit gdb/dwarf2/read.c:6774 (gdb+0x8304d7)^M\n    #2 operator() gdb/dwarf2/read.c:7098 (gdb+0x8317be)^M\n    #3 operator() gdbsupport/parallel-for.h:163 (gdb+0x872380)^M\n...\nand this via the PU import:\n...\n    #1 cooked_indexer::ensure_cu_exists(cutu_reader*, dwarf2_per_objfile*, \\\n    sect_offset, bool,  bool) gdb/dwarf2/read.c:17964 (gdb+0x85c43b)^M\n    #2 cooked_indexer::index_imported_unit(cutu_reader*, unsigned char const*, \\\n    abbrev_info const*) gdb/dwarf2/read.c:18248 (gdb+0x85d8ff)^M\n    #3 cooked_indexer::index_dies(cutu_reader*, unsigned char const*, \\\n    cooked_index_entry const*, bool) gdb/dwarf2/read.c:18302 (gdb+0x85dcdb)^M\n    #4 cooked_indexer::make_index(cutu_reader*) gdb/dwarf2/read.c:18443 \\\n    (gdb+0x85e68a)^M\n    #5 process_psymtab_comp_unit gdb/dwarf2/read.c:6812 (gdb+0x830879)^M\n    #6 operator() gdb/dwarf2/read.c:7098 (gdb+0x8317be)^M\n    #7 operator() gdbsupport/parallel-for.h:171 (gdb+0x8723e2)^M\n...\n\nFix this by setting the field earlier, in read_comp_units_from_section.\n\nThe write in cutu_reader::cutu_reader() is still needed, in case\nread_comp_units_from_section is not used (run the test-case with say, target\nboard cc-with-gdb-index).\n\nMake the write conditional, such that it doesn\u0027t trigger if the field is\nalready set by read_comp_units_from_section.  Instead, verify that the\nfield already has the value that we\u0027re trying to set it to.\n\nMove this logic into into a member function set_version (in analogy to the\nalready present member function version) to make sure it\u0027s used consistenly,\nand make the field private in order to enforce access through the member\nfunctions, and rename it to m_dwarf_version.\n\nWhile we\u0027re at it, make sure that the version is set before read, to avoid\nsay returning true for \"per_cu.version () \u003c 5\" if \"per_cu.version () \u003d\u003d 0\".\n\nTested on x86_64-linux.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "d5088395fb1f32f11d38349bbe8a272ea657646f",
      "old_mode": 33188,
      "old_path": "gdb/dwarf2/read.c",
      "new_id": "410cc909c2601dd59a6921b111d6a628325b1abb",
      "new_mode": 33188,
      "new_path": "gdb/dwarf2/read.c"
    },
    {
      "type": "modify",
      "old_id": "51e02dfc4572761ce80d814fe11c4d0e0a28ac6f",
      "old_mode": 33188,
      "old_path": "gdb/dwarf2/read.h",
      "new_id": "b7a03933aa52ea99c68be0753f46d579587ea4e8",
      "new_mode": 33188,
      "new_path": "gdb/dwarf2/read.h"
    }
  ]
}
