Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix missing error handling in interpreter queues when listing queues or sharing a queue between interpreters.
Memory allocation failures now raise :exc:`MemoryError` instead of returning without an exception set.
18 changes: 16 additions & 2 deletions Modules/_interpqueuesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,9 +1042,10 @@ _queues_list_all(_queues *queues, int64_t *p_count)
{
struct queue_id_and_info *qids = NULL;
PyThread_acquire_lock(queues->mutex, WAIT_LOCK);
struct queue_id_and_info *ids = PyMem_NEW(struct queue_id_and_info,
struct queue_id_and_info *ids = PyMem_New(struct queue_id_and_info,
(Py_ssize_t)(queues->count));
if (ids == NULL) {
PyErr_NoMemory();
goto done;
}
_queueref *ref = queues->head;
Expand Down Expand Up @@ -1321,13 +1322,26 @@ static void *
_queueid_xid_new(int64_t qid)
{
_queues *queues = _get_global_queues();
if (_queues_incref(queues, qid) < 0) {
int err = _queues_incref(queues, qid);
if (err < 0) {
assert(err == ERR_QUEUE_NOT_FOUND);
PyObject *mod = _get_current_module();
if (mod == NULL) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_SystemError,
"missing " MODULE_NAME_STR " module");
}
return NULL;
}
(void)handle_queue_error(err, mod, qid);
Py_DECREF(mod);
return NULL;
}

struct _queueid_xid *data = PyMem_RawMalloc(sizeof(struct _queueid_xid));
if (data == NULL) {
_queues_decref(queues, qid);
PyErr_NoMemory();
return NULL;
}
data->qid = qid;
Expand Down
Loading