Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 6e74898724f540499ea2cae0ee7d26f140625421
Ticket: 5da26d47606ec035175a8579852d181b0a53eaa7
Tcl_LoadFile() segfaults if "interp" is NULL
User & Date: rkeene on 2015-10-05 16:37:39
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    Calling Tcl_LoadFile() with interp as NULL results in Tcl_ResetResult(NULL) being called.  Tcl_ResetResult(NULL) segfaults rather early on after attempting to dereference NULL as if it were a pointer to a (Tcl_Interp).
    
    <hr>
    GDB output:
    <pre><code>
        Program received signal SIGSEGV, Segmentation fault.
        0x00007ffff7b43a29 in ResetObjResult.isra.0 () from /opt/appfs/core.appfs.rkeene.org/tcl/linux-x86_64/8.6.3/lib/libtcl8.6.so
        (gdb) bt
        #0  0x00007ffff7b43a29 in ResetObjResult.isra.0 () from /opt/appfs/core.appfs.rkeene.org/tcl/linux-x86_64/8.6.3/lib/libtcl8.6.so
        #1  0x00007ffff7b444f0 in Tcl_ResetResult () from /opt/appfs/core.appfs.rkeene.org/tcl/linux-x86_64/8.6.3/lib/libtcl8.6.so
        #2  0x00007ffff7b2622b in Tcl_LoadFile () from /opt/appfs/core.appfs.rkeene.org/tcl/linux-x86_64/8.6.3/lib/libtcl8.6.so
        #3  0x00007ffff4c00d5c in tclpkcs11_int_load_module () from /opt/appfs/rkeene.org/tclpkcs11/platform/latest/lib/tclpkcs110.9.10/tclpkcs11.so
    <code></pre>
    
    <hr>
    Code:
    <pre><code>
    MODULE_SCOPE void *tclpkcs11_int_load_module(const char *pathname) {
            int tcl_rv;
            Tcl_Obj *pathnameObj;
            Tcl_LoadHandle *new_handle;
            new_handle = (Tcl_LoadHandle *) ckalloc(sizeof(*new_handle));
            pathnameObj = Tcl_NewStringObj(pathname, -1);
            Tcl_IncrRefCount(pathnameObj);
            tcl_rv = Tcl_LoadFile(NULL, pathnameObj, NULL, 0, NULL, new_handle);
            Tcl_DecrRefCount(pathnameObj);
    ...
    </code></pre>
    
  5. foundin changed to: "8.6.3"
  6. is_private changed to: "0"
  7. login: "rkeene"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "1dad915564694f09d87e0c4dedb8bdba082b5626"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "rkeene"
  14. subsystem changed to: "40. Dynamic Loading"
  15. title changed to: "Tcl_LoadFile() segfaults if "interp" is NULL"
  16. type changed to: "Bug"