Skip to content
Tcl Source Code History Of Ticket 3565462fffffffffffffffffffffffffffffffff
Login

History Of Ticket 3565462fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 3565462fffffffffffffffffffffffffffffffff

  1. Ticket change [3b0831add2] (rid 112659) by tobv on 2012-09-07 09:24:52:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Hi, 
      
      We believe we have found a bug in the code for 64 bit system. 
      
      Our code that causes it is: 
      int socketfd;
      if (Tcl_GetChannelHandle(channel, TCL_READABLE, (ClientData)&socketfd) != TCL_OK) {
      return TCL_ERROR;
      }
      
      The cause is in: 
      In Tcl_GetChannelHandle() (tclIO.c)
      
          ClientData handle;
          result = (chanPtr->typePtr->getHandleProc)(chanPtr->instanceData,
          direction, &handle);
          if (handlePtr) {
      *handlePtr = handle;
          }
      
      and
      tclUnixChan.c
      
      static int
      TcpGetHandleProc(
          ClientData instanceData,/* The socket state. */
          int direction,/* Not used. */
          ClientData *handlePtr)/* Where to store the handle. */
      {
          TcpState *statePtr = (TcpState *) instanceData;
      
          *handlePtr = (ClientData) INT2PTR(statePtr->fd);
          return TCL_OK;
      }
      
      where it in the end tries to set *handlePtr (pointer to an int) to a long value.
      
      And the solution should be: 
      
      Solution:
      
      In Tcl_GetChannelHandle() (tclIO.c)
      
          result = (chanPtr->typePtr->getHandleProc)(chanPtr->instanceData,
          direction, handlePtr);
      
      In TcpGetHandleProc (tclUnixChan.c)
      
      tclUnixChan.c
      
      static int
      TcpGetHandleProc(
          ClientData instanceData,/* The socket state. */
          int direction,/* Not used. */
          ClientData *handlePtr)/* Where to store the handle. */
      {
          TcpState *statePtr = (TcpState *) instanceData;
      
          if (handlePtr) {
      *handlePtr = statePtr->fd;
          }
          return TCL_OK;
      }
      
      System information: 
      System information: 
      % parray tcl_platform
      tcl_platform(byteOrder)   = littleEndian
      tcl_platform(machine)     = x86_64
      tcl_platform(os)          = Linux
      tcl_platform(osVersion)   = 2.6.32.29-0.3-default
      tcl_platform(platform)    = unix
      tcl_platform(pointerSize) = 8
      tcl_platform(user)        = xxxxx
      tcl_platform(wordSize)    = 8
      
    4. foundin initialized to: "obsolete: 8.5.12"
    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: "tobv"
    10. subsystem initialized to: "None"
    11. title initialized to: "Segmentation fault on linux 64 bit "
    12. type initialized to: "Bug"
  2. Ticket change [51d766a1e4] (rid 126199) by nijtmans on 2012-09-07 17:06:52:

    1. assignee changed to: "nijtmans"
    2. closedate changed to: "2012-09-07T10:06:52"
    3. closer changed to: "nijtmans"
    4. icomment:
      > int socketfd;
      > if (Tcl_GetChannelHandle(channel, TCL_READABLE, (ClientData)&socketfd) != TCL_OK) {
      >         return TCL_ERROR;
      > }
      Casting a pointer to ClientData hides the compiler error that would
      have been generated otherwise. It's not safe to do something
      like that. Tcl_GetChannelHandle() is documented to return
      ClientData, not an int. Your code should look like:
      ClientData socketfd;
      if (Tcl_GetChannelHandle(channel, TCL_READABLE, &socketfd) != TCL_OK) {
              return TCL_ERROR;
      }
      So, I'm sorry to say it, but it's definitely not a Tcl bug.
      
      
    5. login: "nijtmans"
    6. mimetype: "text/plain"
    7. resolution changed to: "Invalid"
    8. status changed to: "Closed"
    9. username: "nijtmans"
  3. Ticket change [f1c3fca402] (rid 109413) by dkf on 2012-09-07 19:28:47:

    1. icomment:
      I'd have expected to use INT2PTR(socketfd) in this case instead of (ClientData)&socketfd as the latter will point off into no-mans-land once its stack frame goes away. Unix FDs are "small" integers (they usually fit in a 'short', even on 64-bit systems) but the API takes a ClientData because that's needed on other platforms.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"