debug.traceback inside a __close run by coroutine.close lists the suspended body's frames (ref: only the __close frame)

Abierto
#74 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
lua
Área
compilers

Línea de trabajo

Start with the tb3 repro under bin/eigenlua and compare it with the reference output. The frame-hiding logic is in lr_d_frame (src/runtime.eigs around lines 3041-3046), which checks r.coclose set by lr_co_close (src/rt_coroutine.eigs, lines 224-229 and 245-264). lr_d_traceback (src/runtime.eigs around line 3180) walks lr_d_framet directly and does not check coclose. Done means tb1, tb2 and tb3 match the reference byte for byte, plus a Tier D row that passes tools/grade.sh.

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

Descripción

Summary

debug.traceback called inside a __close that coroutine.close runs on a suspended coroutine lists the suspended body's frames ([C]: in function 'coroutine.yield' and every Lua frame under it). Lua 5.4.9 lists only the __close frame: lua_closethread calls the pending closes without leaving the body's frames on the coroutine stack.

This is pre-existing. It shows on origin/main a302c4e with no close error at all, and it is not caused by the #73 fix (it was found by the blind critic of that fix, hq#58 Wave 2).

Minimal repro (tb3)

local function F(f) return setmetatable({}, {__close = f}) end
local co = coroutine.create(function()
  local a <close> = F(function(_, e) print("a", e); print((debug.traceback("tb", 1):gsub("\t", "  "))) end)
  coroutine.yield()
end)
coroutine.resume(co)
print(coroutine.close(co))

Reference (.ref/bin/lua, 5.4.9), rc=0:

a	nil
tb
stack traceback:
  tb3.lua:3: in function <tb3.lua:3>
true

EigenLua on main a302c4e (EigenScript v0.48.0), rc=0:

a	nil
tb
stack traceback:
  tb3.lua:3: in function <tb3.lua:3>
  [C]: in function 'coroutine.yield'
  tb3.lua:4: in function <tb3.lua:2>
true

Two variants show the same extra frames:

  • tb2: as tb3, plus a second local b <close> = F(function(_, e) end) and the yield inside a nested local function deep() coroutine.yield() end; deep(). Main prints the __close frame plus [C]: in function 'coroutine.yield', deep's frame and the body's frame; the reference prints only the __close frame.
  • tb1: as tb2, but b's __close raises error("eb", 0). On main a never ran (that was #73). With the #73 fix a runs and prints a eb and then the same extra frames; the reference prints only the __close frame and false eb.

Cause

lr_d_frame (src/runtime.eigs:3041-3046 on a302c4e) hides the closed coroutine's frames while r.coclose is set (lr_co_close, src/rt_coroutine.eigs:224-229 and 245-264), so debug.getinfo already agrees with the reference. lr_d_traceback (src/runtime.eigs:3180) walks lr_d_framet directly and never consults coclose, so the walker shows the frames that getinfo hides.

Not #16 (that was debug.traceback(thread, ...) walking the caller's stack).

Done when

  • tb1, tb2 and tb3 above print the reference's output byte for byte under bin/eigenlua (rc 0).
  • A new Tier D row (for example corpus/D/co_close_traceback.lua) covering all three MATCHes under tools/grade.sh --candidate bin/eigenlua --tier D, with no new DIVERGE elsewhere.
  • debug.traceback with an explicit level (0, 1, 2) inside such a __close, and debug.traceback(co) called on the closing coroutine from inside its own __close, also match the reference (in the same row).

Generated by Claude Code

Lenguaje dominante
Lua
Estrellas
0
Forks
0
Merge medio
43 min
PR fusionados (30 d)
10

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

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 InauguralSystems/EigenLua

Todos los issues de InauguralSystems/EigenLua

Issues similares

Más issues de Lua

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.