Tcl Source Code

View Ticket
Login
Ticket UUID: 2910094
Title: [info frame] broken in coros
Type: Bug Version: obsolete: 8.6b1.1
Submitter: msofer Created on: 2009-12-07 16:14:34
Subsystem: 17. Commands I-L Assigned To: andreas_kupries
Priority: 8 Severity:
Status: Closed Last Modified: 2009-12-08 03:50:12
Resolution: Fixed Closed By: msofer
    Closed on: 2009-12-07 20:50:12
Description:
% proc stack {} {
    puts LEVEL:[set lev [info frame]]
    for {set i 1} {$i < $lev} {incr i} {
puts [info frame $i]
    }
}
% stack
LEVEL:2
type eval line 1 cmd stack level 1
% proc a {} stack
% a
LEVEL:3
type eval line 1 cmd a level 2
type proc line 1 cmd stack proc ::a level 1
% coroutine aa a
LEVEL:5
bad level "1"
User Comments: msofer added on 2009-12-08 03:50:12:

allow_comments - 1

That did it; committed.

andreas_kupries added on 2009-12-08 02:59:48:
Assuming the alternative is true the fix would be to remove the +1 in line 1103 of file tclCmdIL.c, rev 1.174.

andreas_kupries added on 2009-12-08 02:57:20:
An alternative is that the calculation of levels in the coroutine is off by one, i.e. that info frame should show only the coro stack up to what we see in my output as level 2.

andreas_kupries added on 2009-12-08 02:55:46:

IP - Comment Removed: 204.244.102.2

andreas_kupries added on 2009-12-08 02:53:59:
I confirm, using my own frame dumper (which starts from the current from down to 1, so I am able to see some output before it croaks, my code is attached here). Output is

andreask@gila:~/workbench/Coro280> ./install/tcl86/bin/tclsh8.6
% source infoframedebug.tcl
% debugframes
FRAME   2 {type source line 6 file infoframedebug.tcl cmd {info frame $level} proc ::debugframes level 0}
FRAME   1 {type eval line 1 cmd debugframes level 1}

% proc a {} debugframes
% a
FRAME   3 {type source line 6 file infoframedebug.tcl cmd {info frame $level} proc ::debugframes level 0}
FRAME   2 {type proc line 1 cmd debugframes proc ::a level 1}
FRAME   1 {type eval line 1 cmd a level 2}

% coroutine aa a
FRAME   5 {type source line 6 file infoframedebug.tcl cmd {info frame $level} proc ::debugframes level 0}
FRAME   4 {type proc line 1 cmd debugframes proc ::a level 1}
FRAME   3 {type eval line 1 cmd a}
FRAME   2 {type eval line 1 cmd {coroutine aa a} level 2}
bad level "1"
% exit

It seems the trouble is where it tries to access the stack frames above the coroutine invokation.

The bad level is either thrown for out of range, or, for in-range numbers, if the loop in lines 1142-1148 (tclCmIL.c, rev 1.174) is not finding a frame. That would indicate that the framePtr->nextPtr chain is broken at the point of main to coro transition.

This is likely managed in the code switching between coros, right ?

andreas_kupries added on 2009-12-08 02:53:54:
I confirm, using my own frame dumper (which starts from the current from down to 1, so I am able to see some output before it croaks, my code is attached here). Output is

andreask@gila:~/workbench/Coro280> ./install/tcl86/bin/tclsh8.6
% source infoframedebug.tcl
% debugframes
FRAME   2 {type source line 6 file infoframedebug.tcl cmd {info frame $level} proc ::debugframes level 0}
FRAME   1 {type eval line 1 cmd debugframes level 1}

% proc a {} debugframes
% a
FRAME   3 {type source line 6 file infoframedebug.tcl cmd {info frame $level} proc ::debugframes level 0}
FRAME   2 {type proc line 1 cmd debugframes proc ::a level 1}
FRAME   1 {type eval line 1 cmd a level 2}

% coroutine aa a
FRAME   5 {type source line 6 file infoframedebug.tcl cmd {info frame $level} proc ::debugframes level 0}
FRAME   4 {type proc line 1 cmd debugframes proc ::a level 1}
FRAME   3 {type eval line 1 cmd a}
FRAME   2 {type eval line 1 cmd {coroutine aa a} level 2}
bad level "1"
% exit

It seems the trouble is where it tries to access the stack frames above the coroutine invokation.

The bad level is either thrown for out of range, or, for in-range numbers, if the loop in lines 1142-1148 (tclCmIL.c, rev 1.174) is not finding a frame. That would indicate that the framePtr->nextPtr chain is broken at the point of main to coro transition.

This is likely managed in the code switching between coros, right ?

andreas_kupries added on 2009-12-08 02:18:23:

File Added - 354261: infoframedebug.tcl

Attachments: