)]}'
{
  "commit": "f84a4db958af0ee1521acdf69eb2be38ea2e66a3",
  "tree": "4217ea7569d4b9e5be3149fa41dafee590fd29c3",
  "parents": [
    "4c1459870634074ea2266ec5755371eec3948963"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Tue Jun 03 17:23:10 2025 +0100"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Wed Jun 04 09:39:33 2025 +0100"
  },
  "message": "gdb/python/guile: fix segfault from nested prefix command creation\n\nA commit I recently pushed:\n\n  commit 0b5023cc71d3af8b18e10e6599a3f9381bc15265\n  Date:   Sat Apr 12 09:15:53 2025 +0100\n\n      gdb/python/guile: user created prefix commands get help list\n\ncan trigger a segfault if a user tries to create nested prefix\ncommands.  For example, this will trigger a crash:\n\n  (gdb) python gdb.ParameterPrefix(\"prefix-1\", gdb.COMMAND_NONE)\n  (gdb) python gdb.ParameterPrefix(\"prefix-1 prefix-2\", gdb.COMMAND_NONE)\n\n  Fatal signal: Segmentation fault\n  ... etc ...\n\nIf the user adds an actual parameter under \u0027prefix-1\u0027 before creating\n\u0027prefix-2\u0027, then everything is fine:\n\n  (gdb) python gdb.ParameterPrefix(\"prefix-1\", gdb.COMMAND_NONE)\n  (gdb) python gdb.Parameter(\u0027prefix-1 param-1\u0027, gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)\n  (gdb) python gdb.ParameterPrefix(\"prefix-1 prefix-2\", gdb.COMMAND_NONE)\n\nThe mistake in the above patch is in how gdbpy_parse_command_name is\nused.  The BASE_LIST output argument from this function points to the\nlist of commands for the prefix, not to the prefix command itself.\n\nSo when gdbpy_parse_command_name is called for \u0027prefix-1 prefix-2\u0027,\nBASE_LIST points to the list of commands associated with \u0027prefix-1\u0027,\nnot to the actual \u0027prefix-1\u0027 cmd_list_element.\n\nBack in cmdpy_init, from where gdbpy_parse_command_name was called, I\nwas walking back from the first entry in BASE_LIST to figure out if\nthis was a \"show\" prefix command or not.  However, if BASE_LIST is\nempty then there is no first item, and this would trigger the\nsegfault.\n\nThe solution it to extend gdbpy_parse_command_name to also return the\nprefix cmd_list_element in addition to the existing values.  With this\ndone, and cmdpy_init updated, the segfault is now avoided.\n\nThere\u0027s a new test that would trigger the crash without the patch.\n\nAnd, of course, the above commit also broke guile in the exact same\nway.  And the fix is exactly the same.  And there\u0027s a guile test too.\n\nNOTE: We should investigate possibly sharing some of this boiler plate\nhelper code between Python and Guile.  But not in this commit.\n\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "3101882fb2c1023ff91eb00f01c1419b3abad135",
      "old_mode": 33188,
      "old_path": "gdb/guile/guile-internal.h",
      "new_id": "60a8bf3a8db8b3bcf23827f5bf73e8a65b233abb",
      "new_mode": 33188,
      "new_path": "gdb/guile/guile-internal.h"
    },
    {
      "type": "modify",
      "old_id": "565d58890b82382756f393bb73130a4dc61199d6",
      "old_mode": 33188,
      "old_path": "gdb/guile/scm-cmd.c",
      "new_id": "74646f35ea2618a470517396d67bf4830171d333",
      "new_mode": 33188,
      "new_path": "gdb/guile/scm-cmd.c"
    },
    {
      "type": "modify",
      "old_id": "5b4f8138aeade55366f7a1b1391b6f932dc16452",
      "old_mode": 33188,
      "old_path": "gdb/python/py-cmd.c",
      "new_id": "e8c29042430b3b907bbe1a205272bd199d9081c1",
      "new_mode": 33188,
      "new_path": "gdb/python/py-cmd.c"
    },
    {
      "type": "modify",
      "old_id": "bdccb265441e7f7fb3382abc7736b30b0a6dadf2",
      "old_mode": 33188,
      "old_path": "gdb/python/python-internal.h",
      "new_id": "7f4237eecc2171b90d19e144e2002e58a9fa2a40",
      "new_mode": 33188,
      "new_path": "gdb/python/python-internal.h"
    },
    {
      "type": "modify",
      "old_id": "bf0d7df5f26aa9fce1f5e1375977199f3c85aad4",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.guile/scm-parameter.exp",
      "new_id": "e35428a8495281308ed8cd06b1fe5670bc531ed0",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.guile/scm-parameter.exp"
    },
    {
      "type": "modify",
      "old_id": "69cbb90ab214aac597d6261679809b5502cdd59f",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.python/py-parameter-prefix.exp",
      "new_id": "eb09fe7e85da428f98189fe2f5e86fcda0462828",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.python/py-parameter-prefix.exp"
    }
  ]
}
