Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

JS_ThrowStackOverflow may overflow stack itself

Abierto
#893 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
c
Área
backend

Línea de trabajo

Read build_backtrace() in quickjs.c around the stack-heavy JSCallSiteData allocation and the char buf[256] local mentioned in the issue. Trace how JS_ThrowStackOverflow() reaches backtrace construction, then assess the proposed approaches and their stack requirements. Done means throwing at the configured stack limit cannot itself overflow the physical stack.

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

Descripción

Hello,

QuickJS supports stack limiting with JS_SetMaxStackSize(), and many operations check remaining stack size before alloca() or calling functions. These checks call JS_ThrowStackOverflow(), which should throw corresponding exception. Obviously this exception has a stacktrace.
But the problem is that build_backtrace() function consumes huge amount of stack itself. For example, just this line implies x64 JSCallSiteData structs, each of them is x3 JSValue (+ 9 bytes + align), and each JSValue may be up to 16 bytes on x64 machine (depending on flags). This gives us 64 * aligned(3 * 16 + 9) = 3840 bytes. The full call chain performed to fill backtrace also includes other stack-heavy things, like char buf[256]. Since the exception itself was thrown because we've already reached stack limit, there is a risk of "physically" overflowing the stack if the limit was configured somewhat near the real stack size.

For now the only workaround is to set limit way lower than real stack size, but the needed spare space seems to be unpredictable.
Proposed solutions:

  1. Calculate and enforce maximum stack consumption for JS_ThrowStackOverflow() and specify it in documentation;
  2. Make build_backtrace() and other corresponding functions less stack-heavy, moving every possible local value on (pre-allocated?) heap buffer;
  3. Add some stack checks to throwing-related functions and fallback to skipping backtrace if building stacktrace is impossible.
Lenguaje dominante
C
Estrellas
3.9k
Forks
389
Merge medio
4 d 1 h
PR fusionados (30 d)
24

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

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.

Más de quickjs-ng/quickjs

Todos los issues de quickjs-ng/quickjs

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.