Skip to content
Merged
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 a crash caused when running out of memory creating a
:mod:`!_interpchannels` channel. Now a :exc:`MemoryError` is correctly raised.
11 changes: 4 additions & 7 deletions Modules/_interpchannelsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
#define ERR_CHANNEL_INTERP_CLOSED -4
#define ERR_CHANNEL_EMPTY -5
#define ERR_CHANNEL_NOT_EMPTY -6
#define ERR_CHANNEL_MUTEX_INIT -7
#define ERR_CHANNEL_MUTEX_INIT -7 // currently unused
#define ERR_CHANNELS_MUTEX_INIT -8
#define ERR_NO_NEXT_CHANNEL_ID -9
#define ERR_CHANNEL_CLOSED_WAITING -10
Expand Down Expand Up @@ -427,10 +427,6 @@
"if not empty (try force=True)",
cid);
}
else if (err == ERR_CHANNEL_MUTEX_INIT) {
PyErr_SetString(state->ChannelError,
"can't initialize mutex for new channel");
}
else if (err == ERR_CHANNELS_MUTEX_INIT) {
PyErr_SetString(state->ChannelError,
"can't initialize mutex for channel management");
Expand Down Expand Up @@ -1744,7 +1740,8 @@
{
PyThread_type_lock mutex = PyThread_allocate_lock();
if (mutex == NULL) {
return ERR_CHANNEL_MUTEX_INIT;
PyErr_NoMemory();
return -1;
}
_channel_state *chan = _channel_new(mutex, defaults);
if (chan == NULL) {
Expand Down Expand Up @@ -2938,7 +2935,7 @@

int64_t cid = channel_create(&_globals.channels, defaults);
if (cid < 0) {
(void)handle_channel_error(-1, self, cid);
(void)handle_channel_error(cid, self, cid);

Check warning on line 2938 in Modules/_interpchannelsmodule.c

View workflow job for this annotation

GitHub Actions / Windows / Build and test (arm64)

'function': conversion from 'int64_t' to 'int', possible loss of data [C:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Check warning on line 2938 in Modules/_interpchannelsmodule.c

View workflow job for this annotation

GitHub Actions / Windows / Build and test (x64)

'function': conversion from 'int64_t' to 'int', possible loss of data [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Check warning on line 2938 in Modules/_interpchannelsmodule.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64)

'function': conversion from 'int64_t' to 'int', possible loss of data [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Check warning on line 2938 in Modules/_interpchannelsmodule.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (arm64)

'function': conversion from 'int64_t' to 'int', possible loss of data [C:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]
return NULL;
}
module_state *state = get_module_state(self);
Expand Down
Loading