python / python/cpython

Many places have missing `PyErr_NoMemory()` call after failing memory allocation

オープン
#151,126 コメント 2 件 リアクション 0 件 担当者 1 名 GitHub で見る

@sobolevn がすでに取り組んでいます。

2026年6月9日 から。

interpreter-core type-crash
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Crash report

  1. remove_unused_consts in Python/flowgraph.c

When PyMem_Malloc(nconsts * sizeof(Py_ssize_t)); fails, we need to set an exception.

https://github.com/python/cpython/blob/29a920e80e21490b5bdb7178373f80fe606a4403/Python/flowgraph.c#L3267-L3283

  1. gethandlelist and getattributelist in _winapi.c

This place misses it:

https://github.com/python/cpython/blob/9fdbade99e6bcc607d9f12416bfca5bbf94022b9/Modules/_winapi.c#L1196-L1198

All other error paths set exceptions, except this if:

https://github.com/python/cpython/blob/9fdbade99e6bcc607d9f12416bfca5bbf94022b9/Modules/_winapi.c#L1278-L1282

  1. _channelends_new in Modules/_interpchannelsmodule.c

https://github.com/python/cpython/blob/3ca93ab198497da9451101019b67c52e7873377d/Modules/_interpchannelsmodule.c#L920-L926

Later we check for errors in handle_channel_error, it requires either setting err to non -1 or to set Python exception. Both are false, it fails with the assertion failure.

Linked PRs
  • gh-151127
  • gh-151134
  • gh-151135
  • gh-151136
  • gh-151137
  • gh-151154
  • gh-151180
  • gh-151181
  • gh-151182
  • gh-151239
  • gh-151265
  • gh-151266
  • gh-151336
  • gh-151338
  • gh-151339
  • gh-151360
  • gh-151361
  • gh-151362
  • gh-151382
  • gh-151398
  • gh-151399
  • gh-151400
  • gh-151580
  • gh-151582
  • gh-151588
  • gh-151590
  • gh-151624
  • gh-151639
  • gh-152014
  • gh-152015
  • gh-152016
  • gh-152169
  • gh-152170
  • gh-152177
  • gh-152179
  • gh-152180
  • gh-152181
  • gh-152182
  • gh-152183
  • gh-152184
  • gh-152418
  • gh-152420
  • gh-152421
  • gh-152422
  • gh-152478
  • gh-152677
  • gh-152678
  • gh-152720
  • gh-153215
  • gh-153708
  • gh-153709
  • gh-153710
  • gh-153765
  • gh-156292
  • gh-156299
  • gh-156301

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。