Message338539
I'm not sure if I should include an unit test. WIP patch for that:
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 350ef77163..9c0d0cf41a 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -4718,6 +4718,18 @@ negative_refcount(PyObject *self, PyObject *Py_UNUSED(args))
#endif
+static PyObject *
+corrupted_object(PyObject *self, PyObject *Py_UNUSED(args))
+{
+ PyObject *obj = PyList_New(0);
+ if (obj == NULL) {
+ return NULL;
+ }
+ obj->ob_type = NULL;
+ return obj;
+}
+
+
static PyMethodDef TestMethods[] = {
{"raise_exception", raise_exception, METH_VARARGS},
{"raise_memoryerror", raise_memoryerror, METH_NOARGS},
@@ -4948,6 +4960,7 @@ static PyMethodDef TestMethods[] = {
#ifdef Py_REF_DEBUG
{"negative_refcount", negative_refcount, METH_NOARGS},
#endif
+ {"corrupted_object", corrupted_object, METH_NOARGS},
{NULL, NULL} /* sentinel */
};
Tested manually using this script:
---
import gc, _testcapi, sys
gc.enable_object_debugger(1)
x = _testcapi.corrupted_object()
y = []
y = None
# Debugger should trigger here
x = None
--- |
|
Date |
User |
Action |
Args |
2019-03-21 12:55:24 | vstinner | set | recipients:
+ vstinner, methane, serhiy.storchaka, pablogsal |
2019-03-21 12:55:24 | vstinner | set | messageid: <1553172924.07.0.777143445956.issue36389@roundup.psfhosted.org> |
2019-03-21 12:55:24 | vstinner | link | issue36389 messages |
2019-03-21 12:55:23 | vstinner | create | |
|