Tcl Source Code

View Ticket
Login
2024-08-30
15:49
Merge [8a4c0f4a935f1008]: Info frame: restored return {type precompiled} in case of no frame informa... check-in: c1874a0673 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE
15:48
Merge [e40407c5e808edc3]: Fix [0de6c1d79c] more consistently (an error "bad level" for info instead ... check-in: e543823e6c user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE
15:46
Merge [7077dea20e3be4f4]: Fix for [0de6c1d79c] crash. check-in: 41c4de5887 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE
2024-07-02
14:36
info frame: restored return {type precompiled} in case of no frame information; see [0de6c1d79cfba2e... check-in: 8c2c0a6d7d user: sebres tags: core-8-6-branch
13:39 • Ticket [0de6c1d79c] child invokehidden info frame dereferences NULL status... artifact: 705bba3ab4 user: apnadkarni
12:36
fix crash [0de6c1d79c] more consistently (an error "bad level" for info instead of artifical dummy i... check-in: 67a0bf288e user: sebres tags: core-8-6-branch
12:22
Fix for [0de6c1d79c] crash (cherry-picked from trunk) check-in: c32d6e1118 user: sebres tags: core-8-6-branch
11:37 • Closed ticket [0de6c1d79c]: child invokehidden info frame dereferences NULL</i... artifact: 316306a435 user: apnadkarni
11:34 • New ticket [708b005695] info frame via invokehidden does not return full frame i... artifact: 421c70e20b user: apnadkarni
11:17
Fix for [0de6c1d79c] crash. check-in: 7077dea20e user: apnadkarni tags: trunk, main
2024-05-08
13:58 • Ticket [0de6c1d79c] child invokehidden info frame dereferences NULL status... artifact: f5a87af841 user: apnadkarni
13:30
Start on at least protecting against crashes like [0de6c1d79c] check-in: 21daea98da user: apnadkarni tags: apn-info-frame
2024-03-19
02:56 • New ticket [0de6c1d79c] child invokehidden info frame dereferences NULL. artifact: 294339331a user: andy

Ticket UUID: 0de6c1d79cfba2ea1b21a6732cd9a6e1e1201563
Title: [child invokehidden info frame] dereferences NULL
Type: Bug Created on: 2024-03-19 02:56:44
Submitter: andy Assigned to: nobody
Subsystem: 17. Commands I-L Severity: Minor
Priority: 5 Medium Last modified: 2024-07-02 13:39:12
Status: Closed Closed by: apnadkarni
Resolution: Fixed Closed on: 2024-07-02 13:39:12
Version: 8.6.13
Description:

The following crashes Tcl:

interp create child
child hide info
child invokehidden info frame

This dies in tclCmdIL.c line 1163 because *cmdFramePtrPtr is NULL, since iPtr->cmdFramePtr is NULL.

Replacing "info frame" with "info level" returns 0, no crash.

Backtrace:

#0  InfoFrameCmd (dummy=0x0, interp=0xc5a640, objc=1, objv=0xc6f720)
    at /root/tclkit-dbg/tcl/build/unix/tclCmdIL.c:1163
#1  0x00000000005ca355 in Dispatch (data=0xc43498, interp=0xc5a640, result=0)
    at /root/tclkit-dbg/tcl/build/unix/tclBasic.c:4467
#2  0x00000000005ca3db in TclNRRunCallbacks (interp=0xc5a640, result=0,
    rootPtr=0x0) at /root/tclkit-dbg/tcl/build/unix/tclBasic.c:4503
#3  0x00000000006c7095 in NRPostInvokeHidden (data=0xcad058, interp=0xae4f40,
    result=0) at /root/tclkit-dbg/tcl/build/unix/tclInterp.c:3091
#4  0x00000000005ca3db in TclNRRunCallbacks (interp=0xae4f40, result=0,
    rootPtr=0x0) at /root/tclkit-dbg/tcl/build/unix/tclBasic.c:4503
#5  0x00000000005ccda9 in TclEvalObjEx (interp=0xae4f40, objPtr=0xca0500,
    flags=131072, invoker=0x0, word=0)
    at /root/tclkit-dbg/tcl/build/unix/tclBasic.c:6068
#6  0x00000000005ccd3d in Tcl_EvalObjEx (interp=0xae4f40, objPtr=0xca0500,
    flags=131072) at /root/tclkit-dbg/tcl/build/unix/tclBasic.c:6049
#7  0x00000000006c0131 in Tcl_RecordAndEvalObj (interp=0xae4f40,
    cmdPtr=0xca0500, flags=131072)
    at /root/tclkit-dbg/tcl/build/unix/tclHistory.c:190
#8  0x00000000006f0bfa in Tcl_MainEx (argc=-1, argv=0x7fffffffdb20,
    appInitProc=0x429e16 <TclKit_AppInit>, interp=0xae4f40)
    at /root/tclkit-dbg/tcl/build/unix/tclMain.c:520
#9  0x0000000000429ffe in main (argc=1, argv=0x7fffffffdb18) at main.c:7
User Comments:
apnadkarni added on 2024-05-08 13:58:26:
Still present in 9.0.

`info frame` (TIP 280) is very particular about the presence of an appropriately filled out `CmdFrame` structure. While most of the TclEvalxxx, byte code compiler etc. were adapted with TIP 280 to do the needful, some code paths, including that of interp invokehidden were omitted. Thus the crash.

Fixing `invokehidden` is non trivial (at least from my limited perspective) as with the introduction of NRE, the code path traverses through multiple layers of interp contexts, the NRE trampoline, the namespace ensemble, coroutine contexts.

I've started a branch apn-info-frame to at least try and protect against a crash in some semi-sensible fashion if not give a complete frame dictionary result.

apnadkarni added on 2024-07-02 11:37:05:
Closing as crash is fixed in [7077dea20e]. A follow-on bug remains - logged as [708b005695].

apnadkarni added on 2024-07-02 13:39:12:

@sebres - I do not agree with your [e40407c5e8] commit to raise an error instead of returning "type=precompiled" as better for consistency. Raising an error implies the caller has passed some invalid value. That is not the case here. The fault lies in the implementation, not the caller, in not having frame information available. So it seems more reasonable to return something that says "frame information not available" as opposed to something that tells the caller they made an error. It's misleading.

Moreover, with the above commit

% child invokehidden info frame
1
% child invokehidden info frame 0
bad level "0"
% child invokehidden info frame 1
bad level "1"

does not seem consistent at all. info frame returns a level but then you try to get information and it says bad level.

The dummied up use of "precompiled" as stated in comments is really in place of "framinfonotavailable" because the former also has no frame info available. Adding another type would require a TIP.

This is something I am not going to argue further as it is not that important to me. But if you change your mind, I'd prefer not to raise an error.