TIP 571: Make TclX's profiler work properly with Tcl 8.6

Login
Author:         Rami Khaldi <[email protected]>
State:          Withdrawn
Type:           Project
Tcl-Version:    8.6

Abstract

The aim of this TIP is to make the TCLX's profiler working with Tcl 8.6. The fix was only required in the Tclx library. No changes have been occurred in Tcl core.

Analysis

The profiler has exited with segmentation fault, as it has attempted to access to forbidden memory region. The exception has been thrown in function: ProfObjCommandEval:

"infoPtr->savedCmdInfo.objProc" could have a Null value. It happens when using the NRE tailcall command. By disabling the profile trace of tailcall (We don't want to profile the tailcall itself. As it can only be called in a procedure/lambda context), the issue has been solved.

Example

profile on

proc sayHello {args} {

    after 2500

    puts hello

}

sayHello

sayHello

proc nre_proc {n} {

    puts "call: n := $n"

    incr n;

    if {$n < 10} {

            tailcall nre_proc $n

    }

}

nre_proc 0

profile off res;

profrep res cpu profdata.txt;

Result:

TODO: Better format

------------------------ -------------- ----------- ----------
Procedure Call Stack Calls Real Time CPU Time
------------------------ -------------- ----------- ----------
global 1 68082 84
sayHello 2 5292 21
history 13 0 11
nre_proc 10 0 0
tcl::HistAdd 13 0 0