)]}'
{
  "commit": "c0afd99439fea90c1e93e5add7eac06cf533bb3e",
  "tree": "6acf9f11d9e52c229dd23e399a9cedd63781db59",
  "parents": [
    "906c2c65649bb5d1d4aebe3bafd48f5a23d78ff2"
  ],
  "author": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Wed Jul 26 12:29:28 2023 +0200"
  },
  "committer": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Wed Jul 26 12:29:28 2023 +0200"
  },
  "message": "[gdb/tui] Fix assert in ~gdbpy_tui_window_maker\n\nIn gdb/tui/tui-layout.c, we have:\n...\nstatic window_types_map known_window_types;\n...\nand in gdb/python/py-tui.c:\n...\n  /* A global list of all gdbpy_tui_window_maker objects.  */\n  static intrusive_list\u003cgdbpy_tui_window_maker\u003e m_window_maker_list;\n};\n\n/* See comment in class declaration above.  */\n\nintrusive_list\u003cgdbpy_tui_window_maker\u003e\n  gdbpy_tui_window_maker::m_window_maker_list;\n...\n\nWith a gdb build with -O0 or -O2, the static destructor calling order seems to be:\n- first gdb/tui/tui-layout.c,\n- then gdb/python/py-tui.c.\n\nSo when running test-case gdb.python/tui-window-factory.exp, we see the\nfollowing order of events:\n- the destructor for known_window_types is called, which triggers calling the\n  destructor for the only element E of m_window_maker_list.  The destructor\n  destroys E, and also removes E from m_window_maker_list, leaving it empty.\n- the destructor for m_window_maker_list is called.  It\u0027s empty, so it\u0027s a nop.\n\nHowever, when building gdb with -O2 -flto\u003dauto, the static destructor calling\norder seems to be reversed.\n\nInstead, we have these events:\n- the destructor for m_window_maker_list is called.  This doesn\u0027t destroy it\u0027s\n  only element E, but it does make m_window_maker_list empty.\n- the destructor for known_window_types is called, which triggers calling the\n  destructor for E.  An attempt is done to remove E from m_window_maker_list,\n  but we run into an assertion failure, because the list is empty.\n\nFix this by checking is_linked () before attempting to remove from\nm_window_maker_list, similar to how things were addressed in commit 995a34b1772\n(\"Guard against frame.c destructors running before frame-info.c\u0027s\").\n\nTested on x86_64-linux.\n\nPR tui/30646\nBug: https://sourceware.org/bugzilla/show_bug.cgi?id\u003d30646\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "f47f2278ddabbe3e9342addea53d342df65e589c",
      "old_mode": 33188,
      "old_path": "gdb/python/py-tui.c",
      "new_id": "64f22dbb46278f79285ac380d0aef044ced811ec",
      "new_mode": 33188,
      "new_path": "gdb/python/py-tui.c"
    }
  ]
}
