)]}'
{
  "commit": "f3eee5861743d635ea3a5be7eae3115f85ec9dae",
  "tree": "3ff2f49256e98ba2a90889949c863458d847d6a3",
  "parents": [
    "ec5e9488c0a4adecd7502071ae585f045552051b"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Tue May 23 11:37:41 2023 +0100"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Fri Jun 09 15:36:50 2023 +0100"
  },
  "message": "gdb/debuginfod: cleanup debuginfod earlier\n\nA GDB crash was discovered on Fedora GDB that was tracked back to an\nissue with the way that debuginfod is cleaned up.\n\nThe bug was reported on Fedora 37, 38, and 39.  Here are the steps to\nreproduce:\n\n1. The file /etc/ssl/openssl.cnf contains the following lines:\n\n   [provider_sect]\n   default \u003d default_sect\n   ##legacy \u003d legacy_sect\n   ##\n   [default_sect]\n   activate \u003d 1\n\n   ##[legacy_sect]\n   ##activate \u003d 1\n\n   The bug will occur when the \u0027##\u0027 characters are removed so that the\n   lines in question look like this:\n\n   [provider_sect]\n   default \u003d default_sect\n   legacy \u003d legacy_sect\n\n   [default_sect]\n   activate \u003d 1\n\n   [legacy_sect]\n   activate \u003d 1\n\n2. Clean up any existing debuginfod cache data:\n\n   \u003e rm -rf $HOME/.cache/debuginfod_client\n\n3. Run GDB:\n\n   \u003e gdb -nx -q -iex \u0027set trace-commands on\u0027 \\\n                -iex \u0027set debuginfod enabled on\u0027 \\\n                -iex \u0027set confirm off\u0027 \\\n\t\t-ex \u0027start\u0027 -ex \u0027quit\u0027 /bin/ls\n   +set debuginfod enabled on\n   +set confirm off\n   Reading symbols from /bin/ls...\n   Downloading separate debug info for /usr/bin/ls\n   ... snip ...\n   Temporary breakpoint 1, main (argc\u003d1, argv\u003d0x7fffffffde38) at ../src/ls.c:1646\n   1646    {\n   +quit\n\n   Fatal signal: Segmentation fault\n   ----- Backtrace -----\n   ... snip ...\n\nSo GDB ends up crashing during exit.\n\nWhat\u0027s happening is that when debuginfod is initialised\ndebuginfod_begin is called (this is in the debuginfod library), this\nin turn sets up libcurl, which makes use of openssl.  Somewhere during\nthis setup process an at_exit function is registered to cleanup some\nstate.\n\nBack in GDB the debuginfod_client object is managed using this code:\n\n  /* Deleter for a debuginfod_client.  */\n\n  struct debuginfod_client_deleter\n  {\n    void operator() (debuginfod_client *c)\n    {\n      debuginfod_end (c);\n    }\n  };\n\n  using debuginfod_client_up\n    \u003d std::unique_ptr\u003cdebuginfod_client, debuginfod_client_deleter\u003e;\n\nAnd then a global debuginfod_client_up is created to hold a pointer to\nthe debuginfod_client object.  As a global this will be cleaned up\nusing the standard C++ global object destructor mechanism, which is\nrun after the at_exit handlers.\n\nHowever, it is expected that when debuginfod_end is called the\ndebuginfod_client object will still be in a usable state, that is, we\ndon\u0027t expect the at_exit handlers to have run and started cleaning up\nthe library state.\n\nTo fix this issue we need to ensure that debuginfod_end is called\nbefore the at_exit handlers have a chance to run.\n\nThis commit removes the debuginfod_client_up type, and instead has GDB\nhold a raw pointer to the debuginfod_client object.  We then make use\nof GDB\u0027s make_final_cleanup to register a function that will call\ndebuginfod_end.\n\nAs GDB\u0027s final cleanups are called before exit is called, this means\nthat debuginfod_end will be called before the at_exit handlers are\ncalled, and the crash identified above is resolved.\n\nIt\u0027s not obvious how this issue can easily be tested for. The bug does\nnot appear to manifest when using a local debuginfod server, so we\u0027d\nneed to setup something more involved.  For now I\u0027m proposing this\npatch without any associated tests.\n\nCo-Authored-By: Mark Wielaard \u003cmark@klomp.org\u003e\nCo-Authored-By: Simon Marchi \u003csimark@simark.ca\u003e\nReviewed-By: Tom Tromey \u003ctom@tromey.com\u003e\nReviewed-By: Aaron Merey \u003camerey@redhat.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "5853f420a18d5cacb5d4a667ba37991547aabb50",
      "old_mode": 33188,
      "old_path": "gdb/debuginfod-support.c",
      "new_id": "a41a4c957855ab89412e6075e1ad204a172a3e14",
      "new_mode": 33188,
      "new_path": "gdb/debuginfod-support.c"
    }
  ]
}
