Skip to content
Tcl Source Code History Of Ticket 2860233
Login

History Of Ticket 2860233

Artifacts Associated With Ticket 2860233

  1. Ticket change [87c654b159] (rid 131757) by eriklns on 2009-09-16 19:41:02:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized 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 initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "eriklns"
    10. subsystem initialized to: "None"
    11. title initialized to:
      Calling Tcl_FindCommand() from a shared lib segfaults
      
    12. type initialized to: "Bug"
  2. Ticket change [e6e9fee117] (rid 104371) by eriklns on 2009-09-17 02:41:03:

    1. icomment:
      
      
      File Added - 343243: fc.c
      
      
      
    2. login: "eriklns"
    3. mimetype: "text/plain"
    4. username: "eriklns"
  3. Add attachment "fc.c" [ef796d4b02] (rid 108999) by eriklns on 2009-09-17 02:41:03.

  4. Ticket change [9dab2e51c9] (rid 96348) by eriklns on 2009-09-17 02:42:33:

    1. icomment:
      
      
      File Added - 343244: build
      
      
      
    2. login: "eriklns"
    3. mimetype: "text/plain"
    4. username: "eriklns"
  5. Add attachment "build" [4b97dd8a23] (rid 126740) by eriklns on 2009-09-17 02:42:33.

  6. Add attachment "gdb_backtrace.txt" [dcb01766a9] (rid 114523) by eriklns on 2009-09-17 02:43:27.

  7. Ticket change [ddcfb7c3ea] (rid 114739) by eriklns on 2009-09-17 02:43:27:

    1. icomment:
      
      
      File Added - 343245: gdb_backtrace.txt
      
      
      
    2. login: "eriklns"
    3. mimetype: "text/plain"
    4. username: "eriklns"
  8. Ticket change [339494d970] (rid 106622) by eriklns on 2009-09-17 02:45:12:

    1. icomment:
      
      
      File Added - 343246: tclsh8.4g.png
      
      
      
    2. login: "eriklns"
    3. mimetype: "text/plain"
    4. username: "eriklns"
  9. Add attachment "tclsh8.4g.png" [f5604105e0] (rid 130097) by eriklns on 2009-09-17 02:45:12.

  10. Ticket change [2c7f8047bc] (rid 118915) by dgp on 2009-09-17 05:27:09:

    1. closedate changed to: "2009-09-16T22:27:09"
    2. closer changed to: "dgp"
    3. icomment:
      
      I suspect you compiled your code against Tcl 8.5
      (or later) header files, then tried to [load] into a
      Tcl 8.4 interp.  That does not work.
      
      Compile against the header files of the earliest
      version you wish to support [load]ing into.
      
      
      
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. resolution changed to: "Invalid"
    7. status changed to: "Pending"
    8. username: "dgp"
  11. Ticket change [f8bdff0883] (rid 91592) by eriklns on 2009-09-18 00:22:55:

    1. icomment:
      You are right.
      The header file was picked up from the system-installed include directory, which held header files of tcl8.5 .
      
      Invalid issue indeed.
      
      Sorry for the noise.
      
      
      
    2. login: "eriklns"
    3. mimetype: "text/plain"
    4. status changed to: "Open"
    5. username: "eriklns"
  12. Ticket change [0c1c2c4651] (rid 114119) by dgp on 2009-09-18 00:43:16:

    1. assignee changed to: "dgp"
    2. closedate changed to: "2009-09-17T17:43:16"
    3. closer changed to: "dgp"
    4. icomment:
      
      
      allow_comments - 1
      
      
      One way to help catch such things is to use
      
          Tcl_InitStubs(interp, TCL_VERSION, 0);
      
      so that your extension will demand at the
      time it is [load]ed to have a Tcl interp at least
      as new as the headers it was compiled against.
      When that fails, a [load] error is more useful
      than a crash.
      
      
      
      
      
    5. login: "dgp"
    6. mimetype: "text/plain"
    7. status changed to: "Closed"
    8. username: "dgp"