Skip to content

Commit

Permalink
Removing Py_DECREF(self) that leads to MSAN failure (Google toolcha…
Browse files Browse the repository at this point in the history
…in).

```
==6380==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x5611589c9a58 in Py_DECREF third_party/python_runtime/v3_11/Include/object.h:537:9
...

  Uninitialized value was created by a heap deallocation
    #0 0x5611552757b0 in free third_party/llvm/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:218:3
    google#1 0x56115898e06b in _PyMem_RawFree third_party/python_runtime/v3_11/Objects/obmalloc.c:154:5
    google#2 0x56115898f6ad in PyObject_Free third_party/python_runtime/v3_11/Objects/obmalloc.c:769:5
    google#3 0x561158271bcc in PyObject_GC_Del third_party/python_runtime/v3_11/Modules/gcmodule.c:2407:5
    google#4 0x7f21224b070c in pybind11_object_dealloc third_party/pybind11/include/pybind11/detail/class.h:483:5
    google#5 0x5611589c2ed0 in subtype_dealloc third_party/python_runtime/v3_11/Objects/typeobject.c:1463:5
...
```
  • Loading branch information
Ralf W. Grosse-Kunstleve committed Jan 28, 2024
1 parent a87e484 commit 8a58d6b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions include/pybind11/detail/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ extern "C" inline int tp_init_intercepted(PyObject *self, PyObject *args, PyObje
}
int status = (*derived_tp_init->second)(self, args, kw);
if (status == 0 && !ensure_base_init_functions_were_called(self)) {
Py_DECREF(self);
return -1;
return -1; // No Py_DECREF here.
}
return status;
}
Expand Down

0 comments on commit 8a58d6b

Please sign in to comment.