)]}'
{
  "commit": "0a45af2531d5d8a05fddac62dea25cfa222966ce",
  "tree": "d2dcd9db9197267164393f28f21019256e3312e5",
  "parents": [
    "1c72409f7ff218726b8142d0d03417ccdc32ce0f"
  ],
  "author": {
    "name": "Itamar Oren",
    "email": "itamarost@gmail.com",
    "time": "Mon Mar 23 20:59:26 2026 -0700"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Mon Mar 23 20:59:26 2026 -0700"
  },
  "message": "gh-5991: Fix segfault during finalization related to function_record (#6010)\n\n* gh-5991: Fix segfault during finalization related to function_record\n\nThis patch was developed with assistance from  Claude Code Opus 4.6\n\nHere\u0027s Claude\u0027s explanation of the crash mechanism and some reasoning for the difficulty to repro:\n\n`tp_dealloc_impl` calls `cpp_function::destruct` which:\n1. Calls `std::free()` on function_record string members (`name`, `doc`, `signature`)\n2. Calls `arg.value.dec_ref()` on default argument values\n3. Calls `delete rec` on the function_record\n\nBut it never calls `PyObject_Free(self)` or `Py_DECREF(Py_TYPE(self))`, which are\nrequired for heap types.\n\nDuring `_Py_Finalize`, final GC collects the heap types (which survive module dict\nclearing via `tp_mro` self-references). This triggers a massive cascade:\n`type_dealloc → property_dealloc → meth_dealloc → tp_dealloc_impl → destruct`.\n\nAt scale (~1,200+ function_records), the volume of `delete`/`free` calls corrupts\nheap metadata, causing subsequent `std::free()` to receive garbage pointers → SEGV.\n\n* Add detail::py_is_finalizing() wrapper to deduplicate version-guarded #ifdef blocks\n\nAlso fixes clang-tidy readability-implicit-bool-conversion warnings.\n\nMade-with: Cursor\n\n---------\n\nCo-authored-by: Ralf W. Grosse-Kunstleve \u003crgrossekunst@nvidia.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "d1ab6deeb4d0a1fee7212fe2dff4b5b95eb5cb55",
      "old_mode": 33188,
      "old_path": "include/pybind11/detail/common.h",
      "new_id": "5576ad1300c7198ed4b8d0d5c417e433420ac40d",
      "new_mode": 33188,
      "new_path": "include/pybind11/detail/common.h"
    },
    {
      "type": "modify",
      "old_id": "76d998a3ba4c65f0a299fc61aeb801ffa5913484",
      "old_mode": 33188,
      "old_path": "include/pybind11/pybind11.h",
      "new_id": "454638e299177ce5be5a5cedd111f67545295f16",
      "new_mode": 33188,
      "new_path": "include/pybind11/pybind11.h"
    }
  ]
}
