Tcl Source Code

View Ticket
Login
Ticket UUID: 219011
Title: Thread id's incorrectly assumed to be 32 bit ints on a 64-bi
Type: Bug Created on: 2000-10-26 01:09:18
Submitter: nobody Assigned to: nobody
Subsystem: 49. Threading Severity:
Priority: 2 Last modified: 2000-10-26 08:33:09
Status: Closed Closed by: welch
Resolution: Fixed Closed on: 2000-10-26 01:33:09
Version: final: 8.2.3
Description:
OriginalBugID: 3902 Bug
Version: 8.2.3
SubmitDate: '1999-12-20'
LastModified: '1999-12-20'
Severity: MED
Status: Released
Submitter: techsupp
ChangedBy: hobbs
OS: Digital Unix
OSVersion: Digital Unix 4.0F
Machine: Dec-Alpha
FixedDate: '1999-12-20'
FixedInVersion: 8.3b1
ClosedDate: '2000-10-25'


Name:

Andre Gosselin


ReproducibleScript:

testthread create

  ==> id

testthread send id script

  ==> invalid thread id


ObservedBehavior:

File 'generic/tclThreadTest.c' incorrectly assumes thread ids can be handled as 32 bit integers. 64 bits are in fact needed on an

alpha architecture.


This prevents the following tests (make test) from correctly executing: socket.test, thread.test, unixNotfy.test.


DesiredBehavior:

The thread should execute the script sent to it.


Patch:

The problem can be easily solved by editing lines 259, 376, 613, 274 and 293, changing `int' references (Tcl_NewIntObj(), Tcl_GetIntFromObj(), (int) ) to `long' equivalents. i.e.


*** tclThreadTest.c     Sun Dec 19 23:02:57 1999

--- tcl8.2.3/generic/tclThreadTest.c    Sat Oct 30 07:06:01 1999

***************

*** 256,262 ****

        }

        case THREAD_ID:

            if (objc == 2) {

!       /*IML*/ Tcl_Obj *idObj = Tcl_NewLongObj((long)Tcl_GetCurrentThread());

                Tcl_SetObjResult(interp, idObj);

                return TCL_OK;

            } else {

--- 256,262 ----

        }

        case THREAD_ID:

            if (objc == 2) {

!               Tcl_Obj *idObj = Tcl_NewIntObj((int)Tcl_GetCurrentThread());

                Tcl_SetObjResult(interp, idObj);

                return TCL_OK;

            } else {

***************

*** 271,277 ****

            return TclThreadList(interp);

        }

        case THREAD_SEND: {

!           /*IML*/ long id;

            char *script;

            int wait, arg;


--- 271,277 ----

            return TclThreadList(interp);

        }

        case THREAD_SEND: {

!           int id;

            char *script;

            int wait, arg;

***************

*** 290,296 ****

                wait = 1;

                arg = 2;

            }

!          /*IML*/ if (Tcl_GetLongFromObj(interp, objv[arg], &id) != TCL_OK) {

                return TCL_ERROR;

            }

            arg++;

--- 290,296 ----

                wait = 1;

                arg = 2;

            }

!           if (Tcl_GetIntFromObj(interp, objv[arg], &id) != TCL_OK) {

                return TCL_ERROR;

            }

            arg++;

***************

*** 373,379 ****

      Tcl_ConditionWait(&ctrl.condWait, &threadMutex, NULL);

      Tcl_MutexUnlock(&threadMutex);

      TclFinalizeCondition(&ctrl.condWait);

! /*IML*/    Tcl_SetObjResult(interp, Tcl_NewLongObj((long)id));

      return TCL_OK;

  }

  ^L

--- 373,379 ----

      Tcl_ConditionWait(&ctrl.condWait, &threadMutex, NULL);

      Tcl_MutexUnlock(&threadMutex);

      TclFinalizeCondition(&ctrl.condWait);

!     Tcl_SetObjResult(interp, Tcl_NewIntObj((int)id));

      return TCL_OK;

  }

  ^L

***************

*** 610,616 ****

      Tcl_MutexLock(&threadMutex);

      for (tsdPtr = threadList ; tsdPtr ; tsdPtr = tsdPtr->nextPtr) {

        Tcl_ListObjAppendElement(interp, listPtr,

!       /*IML*/ Tcl_NewLongObj((long)tsdPtr->threadId));

      }

      Tcl_MutexUnlock(&threadMutex);

      Tcl_SetObjResult(interp, listPtr);

--- 610,616 ----

      Tcl_MutexLock(&threadMutex);

      for (tsdPtr = threadList ; tsdPtr ; tsdPtr = tsdPtr->nextPtr) {

        Tcl_ListObjAppendElement(interp, listPtr,

!               Tcl_NewIntObj((int)tsdPtr->threadId));

      }

      Tcl_MutexUnlock(&threadMutex);

      Tcl_SetObjResult(interp, listPtr);


PatchFiles:

tclThreadTest,c




changes made for 8.3b1 
-- 12/20/1999 hobbs