)]}'
{
  "commit": "da8730e8f9255b683f0b5d311ac31cabf84fa1de",
  "tree": "36e2aa333b4f29988ed8e7d28cfdd06529f585fe",
  "parents": [
    "29c70787112e01cd52b53bf14bdcacb0a11e0725"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Sun Sep 08 21:17:55 2024 +0100"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Sun Sep 08 21:17:55 2024 +0100"
  },
  "message": "gdb: fix use of out of scope temporary variable in break-cond-parse.c\n\nThe commit:\n\n  commit c6b486755e020095710c7494d029577ca967a13a\n  Date:   Thu Mar 30 19:21:22 2023 +0100\n\n      gdb: parse pending breakpoint thread/task immediately\n\nIntroduce a use bug where the value of a temporary variable was being\nused after it had gone out of scope.  This was picked up by the\naddress sanitizer and would result in this error:\n\n  (gdb) maintenance selftest create_breakpoint_parse_arg_string\n  Running selftest create_breakpoint_parse_arg_string.\n  \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n  \u003d\u003d2265825\u003d\u003dERROR: AddressSanitizer: stack-use-after-scope on address 0x7fbb08046511 at pc 0x000001632230 bp 0x7fff7c2fb770 sp 0x7fff7c2fb768\n  READ of size 1 at 0x7fbb08046511 thread T0\n      #0 0x163222f in create_breakpoint_parse_arg_string(char const*, std::unique_ptr\u003cchar, gdb::xfree_deleter\u003cchar\u003e \u003e*, int*, int*, int*, std::unique_ptr\u003cchar, gdb::xfree_deleter\u003cchar\u003e \u003e*, bool*) ../../src/gdb/break-cond-parse.c:496\n      #1 0x1633026 in test ../../src/gdb/break-cond-parse.c:582\n      #2 0x163391b in create_breakpoint_parse_arg_string_tests ../../src/gdb/break-cond-parse.c:649\n      #3 0x12cfebc in void std::__invoke_impl\u003cvoid, void (*\u0026)()\u003e(std::__invoke_other, void (*\u0026)()) /usr/include/c++/13/bits/invoke.h:61\n      #4 0x12cc8ee in std::enable_if\u003cis_invocable_r_v\u003cvoid, void (*\u0026)()\u003e, void\u003e::type std::__invoke_r\u003cvoid, void (*\u0026)()\u003e(void (*\u0026)()) /usr/include/c++/13/bits/invoke.h:111\n      #5 0x12c81e5 in std::_Function_handler\u003cvoid (), void (*)()\u003e::_M_invoke(std::_Any_data const\u0026) /usr/include/c++/13/bits/std_function.h:290\n      #6 0x18bb51d in std::function\u003cvoid ()\u003e::operator()() const /usr/include/c++/13/bits/std_function.h:591\n      #7 0x4193ef9 in selftests::run_tests(gdb::array_view\u003cchar const* const\u003e, bool) ../../src/gdbsupport/selftest.cc:100\n      #8 0x21c2206 in maintenance_selftest ../../src/gdb/maint.c:1172\n      ... etc ...\n\nThe problem was caused by three lines like this one:\n\n  thread_info *thr\n    \u003d parse_thread_id (std::string (t.get_value ()).c_str (), \u0026tmptok);\n\nAfter parsing the thread-id TMPTOK would be left pointing into the\ntemporary string which had been created on this line.  When on the\nnext line we did this:\n\n  gdb_assert (*tmptok \u003d\u003d \u0027\\0\u0027);\n\nThe value of *TMPTOK is undefined.\n\nFix this by creating the std::string earlier in the scope.  Now the\ncontents of the string will remain valid when we check *TMPTOK.  The\naddress sanitizer issue is now resolved.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "f5fe308a9236337dccc92f93435e79f9b9987846",
      "old_mode": 33188,
      "old_path": "gdb/break-cond-parse.c",
      "new_id": "b2b1324479f8482aad0b017c2c0e1276e2bcf490",
      "new_mode": 33188,
      "new_path": "gdb/break-cond-parse.c"
    }
  ]
}
