Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 87c654b1593791912c3ff6e787318acb85c0ae2a
Ticket: 2860233fffffffffffffffffffffffffffffffff
Calling Tcl_FindCommand() from a shared lib segfaults
User & Date: eriklns on 2009-09-16 19:41:02
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Observed
    --------
    Tcl8.4 segfaults when calling Tcl_FindCommand() from a stubs enabled shared object.
    
    The segfault occurs at the assembler instruction "call", and the program never makes it into the function. At the moment of the call instruction, the cpu register that holds the memory location to which the call is made, holds the value 0x0.
    
    Running the code from the same shared lib in tclsh8.5 (8.5.7) does not exhibit the problem.
    
    System specification:
    
    % parray tcl_platform
    tcl_platform(byteOrder) = littleEndian
    tcl_platform(machine)   = i686
    tcl_platform(os)        = Linux
    tcl_platform(osVersion) = 2.6.18.8-0.13-default
    tcl_platform(platform)  = unix
    tcl_platform(user)      = erik
    tcl_platform(wordSize)  = 4
    % set tcl_patchLevel
    8.4.19
    
    
    How to reproduce
    ----------------
    Attached to this report is the code for a Tcl extension that registers a new command "findcommand" in file fc.c. Also attached is the build script to produce the shared lib "fc.so". Assuming the completion of the build, you simply do:
    
    > tclsh8.4
    % load ./fc.so
    % findcommand whatever
    Segmentation fault (core dumped)
    
    
    Preliminary analysis
    --------------------
    
    A. ddd inspection
    Attached you find a screendump from the ddd debugger, showing:
    - a breakpoint at the line in the C code where the call to Tcl_FindCommand is made
    - the assembler instructions from that breakpoint up to the call instruction which fails.
    - the cpu registers just before the call instruction.
    Note the 0x0 value in the edx register.
    
    B. backtrace from core dump: see attached file gdb_backtrace.txt
    
    
    Preliminary interpretation
    --------------------------
    Since Tcl itself has calls to Tcl_FindCommand all over the place without them giving cause to complain, there must be something out of the ordinary. Maybe an issue with the stubs interface?
    
    
  4. foundin changed to: "None"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "eriklns"
  10. subsystem changed to: "None"
  11. title changed to:
    Calling Tcl_FindCommand() from a shared lib segfaults
    
  12. type changed to: "Bug"