python / python/cpython

Setting resource.RLIMIT_STACK not working on MacOS

オープン
#142,317 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

OS-mac stdlib type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug report

Bug description:

Running

python3.14 -c "import resource; resource.setrlimit(resource.RLIMIT_STACK, resource.getrlimit(resource.RLIMIT_STACK))"

On MacOS 15.7.2 on my M4 Macbook produces the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import resource; resource.setrlimit(resource.RLIMIT_STACK, resource.getrlimit(resource.RLIMIT_STACK))
                     ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: current limit exceeds maximum limit

Given we are setting the limit to what it was previously, I would not expect this to exceed the maximum limit, because we are not actually changing any limits. The following c program works without issue

#include <stdio.h>
#include <errno.h>
#include <sys/resource.h>

int main(void)
{
    struct rlimit limits = {
        8372224,
        60792480
    };
    int r = setrlimit(RLIMIT_STACK, &limits);
    if (r == -1) {
        perror("setrlimit");
        return 1;
    }
    return 0;
}

(The limits I am setting there are the defaults that python reports).

This seems to be related to #78783.

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Linked PRs
  • gh-150170

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

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

はじめの一歩

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

調査の方向性

macOS で resource.setrlimit と resource.getrlimit を使用する報告済みの Python コマンドから始め、関連する issue #78783 とリンクされた PR gh-150170 を確認します。報告された macOS 構成で、getrlimit が返す値に RLIMIT_STACK を設定しても ValueError が発生しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
operating-systems
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

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

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