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` (pythonGH-129084)

fix UBSan failures for `SemLockObject`
(cherry picked from commit 5ed5572)

Co-authored-by: Bénédikt Tran <[email protected]>
  • Loading branch information
picnixz authored and miss-islington committed Jan 20, 2025
1 parent 03bce18 commit 081f174
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 @@ -23,6 +23,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 @@ -567,8 +569,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 @@ -706,7 +709,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 081f174

Please sign in to comment.