Skip to content

Commit

Permalink
pythongh-111178: fix UBSan failures in `Modules/_multiprocessing/sema…
Browse files Browse the repository at this point in the history
…phore.c` (python#129084)

fix UBSan failures for `SemLockObject`
  • Loading branch information
picnixz authored and srinivasreddy committed Jan 21, 2025
1 parent a9501f2 commit bfec787
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Modules/_multiprocessing/semaphore.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ typedef struct {
char *name;
} SemLockObject;

#define _SemLockObject_CAST(op) ((SemLockObject *)(op))

/*[python input]
class SEM_HANDLE_converter(CConverter):
type = "SEM_HANDLE"
Expand Down Expand Up @@ -576,8 +578,9 @@ _multiprocessing_SemLock__rebuild_impl(PyTypeObject *type, SEM_HANDLE handle,
}

static void
semlock_dealloc(SemLockObject* self)
semlock_dealloc(PyObject *op)
{
SemLockObject *self = _SemLockObject_CAST(op);
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
if (self->handle != SEM_FAILED)
Expand Down Expand Up @@ -718,7 +721,7 @@ _multiprocessing_SemLock___exit___impl(SemLockObject *self,
}

static int
semlock_traverse(SemLockObject *s, visitproc visit, void *arg)
semlock_traverse(PyObject *s, visitproc visit, void *arg)
{
Py_VISIT(Py_TYPE(s));
return 0;
Expand Down

0 comments on commit bfec787

Please sign in to comment.