Skip to content

Commit ef95d6c

Browse files
friedfacebook-github-bot
authored andcommitted
Passing NULL into a Vectorcall is bad -> SIGSEG: address not mapped to object
Summary: User Report https://fburl.com/scuba/coredumper/4xq4bh4i {P1917512020} _PyFunction_Vectorcall calls _PyEval_Vector and @ https://www.internalfb.com/code/fbsource/[c921a6a6cff8]/third-party/python/3.12/Python/ceval.c?lines=1678 calls Py_INCREF on every argument. You can not call that on a NULL so while I didn't see documentation that you can't pass NULLS to vectorcall this is clear code that "you can't pass NULLS to vectorcalls" Replace this with Py_None which can be passed in. Reviewed By: zolyfarkas-fb Differential Revision: D81263333 fbshipit-source-id: 17d57e7309f31b092d9077e909e15b6edaac72fe
1 parent ca64130 commit ef95d6c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Modules/_asynciomodule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,9 @@ FutureObj_repr(FutureObj *fut)
14401440
static void
14411441
Ci_FutureObj_set_awaiter(PyObject *self, PyObject *awaiter)
14421442
{
1443+
if (awaiter == NULL) {
1444+
awaiter = Py_None;
1445+
}
14431446
PyObject *set_awaiter_func = PyObject_GetAttrString(self, "__set_awaiter__");
14441447
if (set_awaiter_func == NULL) {
14451448
PyErr_Clear();

Objects/genobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ _PyGen_Finalize(PyObject *self)
8282
* target awaitable. */
8383
PyObject *yf = _PyGen_yf(gen);
8484
if (yf) {
85-
Ci_PyAwaitable_SetAwaiter(yf, NULL);
85+
Ci_PyAwaitable_SetAwaiter(yf, Py_None);
8686
Py_DECREF(yf);
8787
}
8888
}
@@ -1120,7 +1120,7 @@ Ci_get_awaiter(PyGenObject *gen, void *Py_UNUSED(ignored))
11201120
static void
11211121
Ci_set_awaiter(PyGenObject *gen, PyObject *awaiter)
11221122
{
1123-
if (awaiter == NULL) {
1123+
if (awaiter == NULL || awaiter == Py_None) {
11241124
Py_CLEAR(gen->gi_ci_awaiter);
11251125
} else if (gen->gi_frame_state < FRAME_COMPLETED) {
11261126
Py_XINCREF(awaiter);

0 commit comments

Comments
 (0)