8000 gh-111178: fix UBSan failures in `Objects/codeobject.c` by picnixz · Pull Request #128240 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-111178: fix UBSan failures in Objects/codeobject.c #128240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Objects/codeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1865,11 +1865,12 @@ free_monitoring_data(_PyCoMonitoringData *data)
}

static void
code_dealloc(PyCodeObject *co)
code_dealloc(PyObject *self)
{
_PyObject_ResurrectStart((PyObject *)co);
PyCodeObject *co = (PyCodeObject *)self;
_PyObject_ResurrectStart(self);
notify_code_watchers(PY_CODE_EVENT_DESTROY, co);
if (_PyObject_ResurrectEnd((PyObject *)co)) {
if (_PyObject_ResurrectEnd(self)) {
return;
}

Expand Down Expand Up @@ -1918,7 +1919,7 @@ code_dealloc(PyCodeObject *co)
PyMem_Free(co->_co_cached);
}
if (co->co_weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject*)co);
PyObject_ClearWeakRefs(self);
}
free_monitoring_data(co->_co_monitoring);
#ifdef Py_GIL_DISABLED
Expand Down Expand Up @@ -2198,8 +2199,9 @@ code_linesiterator(PyObject *self, PyObject *Py_UNUSED(args))
}

static PyObject *
code_branchesiterator(PyCodeObject *code, PyObject *Py_UNUSED(args))
code_branchesiterator(PyObject *self, PyObject *Py_UNUSED(args))
{
PyCodeObject *code = (PyCodeObject*)self;
return _PyInstrumentation_BranchesIterator(code);
}

Expand Down Expand Up @@ -2343,7 +2345,7 @@ code__varname_from_oparg_impl(PyCodeObject *self, int oparg)
static struct PyMethodDef code_methods[] = {
{"__sizeof__", code_sizeof, METH_NOARGS},
{"co_lines", code_linesiterator, METH_NOARGS},
{"co_branches", (PyCFunction)code_branchesiterator, METH_NOARGS},
{"co_branches", code_branchesiterator, METH_NOARGS},
{"co_positions", code_positionsiterator, METH_NOARGS},
CODE_REPLACE_METHODDEF
CODE__VARNAME_FROM_OPARG_METHODDEF
Expand All @@ -2358,7 +2360,7 @@ PyTypeObject PyCode_Type = {
"code",
offsetof(PyCodeObject, co_code_adaptive),
sizeof(_Py_CODEUNIT),
(destructor)code_dealloc, /* tp_dealloc */
code_dealloc, /* tp_dealloc */
0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
Expand Down
Loading
0