Setting resource.RLIMIT_STACK not working on MacOS
未關閉
還沒有人認領這個 Issue。
OS-mac
stdlib
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- 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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從報告的、在 macOS 上使用 resource.setrlimit 和 resource.getrlimit 的 Python 命令開始,然後檢視相關的 issue #78783 和連結的 PR gh-150170。在報告的 macOS 設定中,將 RLIMIT_STACK 設為 getrlimit 傳回的值不再引發 ValueError,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- operating-systems
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100