python / python/cpython

Setting resource.RLIMIT_STACK not working on MacOS

Aperta
#142,317 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

OS-mac stdlib type-bug
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con il comando Python segnalato che usa resource.setrlimit e resource.getrlimit su macOS, quindi esamina l’issue correlata #78783 e la PR collegata gh-150170. Il lavoro è completato quando impostare RLIMIT_STACK sui valori restituiti da getrlimit non solleva più ValueError nella configurazione macOS segnalata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
operating-systems
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.