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

Aperta
#74 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
lua
Ambito
compilers

Direzione di ricerca

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.

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

Descrizione

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

Lingua principale
Lua
Stelle
0
Fork
0
Merge medio
43m
PR unite (30g)
10

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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.

Altre issue di InauguralSystems/EigenLua

Tutte le issue di InauguralSystems/EigenLua

Issue simili

Altre issue su Lua

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.