Skip to content

gh-151126: Fix missing memory errors in _interpqueuesmodule.c#151639

Open
lpyu001 wants to merge 3 commits into
python:mainfrom
lpyu001:fix-missing-PyErr_NoMemory-in-interpqc
Open

gh-151126: Fix missing memory errors in _interpqueuesmodule.c#151639
lpyu001 wants to merge 3 commits into
python:mainfrom
lpyu001:fix-missing-PyErr_NoMemory-in-interpqc

Conversation

@lpyu001

@lpyu001 lpyu001 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

@lpyu001 lpyu001 changed the title gh-151126:Fix memory errors in _interpqueuesmodule.c gh-151126:Fix missing memory errors in _interpqueuesmodule.c Jun 18, 2026

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, take a look that _queueid_xid_new also has another problem. It returns NULL here:

_queues *queues = _get_global_queues();
if (_queues_incref(queues, qid) < 0) {
    return NULL;
}

without an exception set. Because _queues_incref sets res = ERR_QUEUE_NOT_FOUND; but sets no exception.

Comment thread Modules/_interpqueuesmodule.c Outdated
@@ -1045,6 +1045,7 @@ _queues_list_all(_queues *queues, int64_t *p_count)
struct queue_id_and_info *ids = PyMem_NEW(struct queue_id_and_info,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we are at it: can you please refactor a deprecated alias PyMem_NEW to be PyMem_New?

@lpyu001 lpyu001 changed the title gh-151126:Fix missing memory errors in _interpqueuesmodule.c gh-151126: Fix missing memory errors in _interpqueuesmodule.c Jun 25, 2026
Comment thread Modules/_interpqueuesmodule.c Outdated
if (_queues_incref(queues, qid) < 0) {
int err = _queues_incref(queues, qid);
if (err < 0) {
PyObject *mod = PyImport_ImportModule(MODULE_NAME_STR);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that this is correct. It can replace an existing error with accidental ImportError. If it fails.

Maybe we can raise the error directly? We know that only ERR_QUEUE_NOT_FOUND can happen.

Or maybe you have other ideas? :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that makes sense. I’m not very familiar with this import/module-state error path,I updated it to avoid importing here and use _get_current_module() before handle_queue_error().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants