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

Skip to content

gh-111178: fix UBSan failures in Modules/_abc.c #128253

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 7, 2025
Merged
Changes from all commits
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
14 changes: 9 additions & 5 deletions Modules/_abc.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ typedef struct {
uint64_t _abc_negative_cache_version;
} _abc_data;

#define _abc_data_CAST(op) ((_abc_data *)(op))

static inline uint64_t
get_cache_version(_abc_data *impl)
{
Expand All @@ -88,8 +90,9 @@ set_cache_version(_abc_data *impl, uin 8000 t64_t version)
}

static int
abc_data_traverse(_abc_data *self, visitproc visit, void *arg)
abc_data_traverse(PyObject *op, visitproc visit, void *arg)
{
_abc_data *self = _abc_data_CAST(op);
Py_VISIT(Py_TYPE(self));
Py_VISIT(self->_abc_registry);
Py_VISIT(self->_abc_cache);
Expand All @@ -98,16 +101,17 @@ abc_data_traverse(_abc_data *self, visitproc visit, void *arg)
}

static int
abc_data_clear(_abc_data *self)
abc_data_clear(PyObject *op)
{
_abc_data *self = _abc_data_CAST(op);
Py_CLEAR(self->_abc_registry);
Py_CLEAR(self->_abc_cache);
Py_CLEAR(self->_abc_negative_cache);
return 0;
}

static void
abc_data_dealloc(_abc_data *self)
abc_data_dealloc(PyObject *self)
{
PyObject_GC_UnTrack(self);
PyTypeObject *tp = Py_TYPE(self);
Expand Down Expand Up @@ -212,7 +216,7 @@ _destroy(PyObject *setweakref, PyObject *objweakref)
}

static PyMethodDef _destroy_def = {
"_destroy", (PyCFunction) _destroy, METH_O
"_destroy", _destroy, METH_O
};

static int
Expand Down Expand Up @@ -964,7 +968,7 @@ _abcmodule_clear(PyObject *module)
static void
_abcmodule_free(void *module)
{
_abcmodule_clear((PyObject *)module);
(void)_abcmodule_clear((PyObject *)module);
}

static PyModuleDef_Slot _abcmodule_slots[] = {
Expand Down
Loading
0