python / python/cpython

Setting resource.RLIMIT_STACK not working on MacOS

Abierto
#142,317 6 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

OS-mac stdlib type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con el comando de Python reportado que usa resource.setrlimit y resource.getrlimit en macOS, y luego revisa el issue relacionado #78783 y el PR vinculado gh-150170. Se considera terminado cuando establecer RLIMIT_STACK en los valores devueltos por getrlimit ya no provoca ValueError en la configuración de macOS reportada.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
operating-systems
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.