Skip to content

Commit

Permalink
[3.12] gh-111178: fix UBSan failures in `Modules/_multiprocessing/sem…
Browse files Browse the repository at this point in the history
…aphore.c` (GH-129084) (#129101)

gh-111178: fix UBSan failures in `Modules/_multiprocessing/semaphore.c` (GH-129084)

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

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
  • Loading branch information
miss-islington and picnixz authored Jan 20, 2025
1 parent 03bce18 commit 9b335cc
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 9b335cc

Please sign in to comment.