)]}'
{
  "commit": "9d3785a8ac15dcc369b8c0b1074c5ca7145cdda7",
  "tree": "1860867e4dadf7fd90d2801bde97bcb86f2ac9da",
  "parents": [
    "e5eca01155e5f6c57337b72cbbe97dc135b66c5e"
  ],
  "author": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Fri Nov 22 19:34:24 2024 +0100"
  },
  "committer": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Fri Nov 22 19:34:24 2024 +0100"
  },
  "message": "[gdb/python] Fix abort on Py_Initialize\n\nI tried out making python initialization fail by passing an incorrect\nPYTHONHOME with python 3.6, and got:\n...\n$ PYTHONHOME\u003dfoo gdb -q\nFatal Python error: Py_Initialize: Unable to get the locale encoding\nModuleNotFoundError: No module named \u0027encodings\u0027\n\nCurrent thread 0x0000ffff89269c80 (most recent call first):\n\nFatal signal: Aborted\n  ...\nAborted (core dumped)\n$\n...\n\nThis is as per spec: when Py_Initialize () fails, a fatal error is raised\nusing Py_FatalError.\n\nThis can be worked around using:\n...\n$ PYTHONHOME\u003dfoo gdb -q -eiex \"set python ignore-environment on\"\n(gdb)\n...\nbut it would be better if gdb didn\u0027t abort.\n\nI found an article [1] describing two solutions:\n- try out Py_Initialize in a separate process, and\n- catch the abort using a signal handler.\n\nThis patch implements the latter solution.\n\nObviously we cannot call into python anymore after the abort, so we avoid\ncalling Py_IsInitialized (), and instead use a new variable py_isinitialized.\n\nThis gets us instead:\n...\n$ PYTHONHOME\u003dfoo gdb -q\nFatal Python error: Py_Initialize: Unable to get the locale encoding\nModuleNotFoundError: No module named \u0027encodings\u0027\n\nCurrent thread 0x0000fffecfd49c80 (most recent call first):\nPython not initialized\n$\n...\n\nTested on aarch64-linux.\n\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n\nPR python/32379\nBug: https://sourceware.org/bugzilla/show_bug.cgi?id\u003d32379\n\n[1] https://stackoverflow.com/questions/7688374/how-to-i-catch-and-handle-a-fatal-error-when-py-initialize-fails\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "820fb585475e326c1f12834a8adc08ed7c8642dd",
      "old_mode": 33188,
      "old_path": "gdb/python/python.c",
      "new_id": "f9d8e8778d50800adc1acd1d8544dca2b2d307b1",
      "new_mode": 33188,
      "new_path": "gdb/python/python.c"
    }
  ]
}
