Tcl Source Code

View Ticket
Login
Ticket UUID: 218831
Title: 8.1.1 + threads + BSD/OS 4.0 do not work well together
Type: Bug Created on: 2000-10-26 01:06:09
Submitter: nobody Assigned to: nobody
Subsystem: 49. Threading Severity:
Priority: 2 Last modified: 2000-10-26 08:30:12
Status: Deleted Closed by: welch
Resolution: Fixed Closed on: 2000-10-26 01:30:12
Version: final: 8.1.1
Description:
OriginalBugID: 2292 Bug
Version: 8.1.1
SubmitDate: '1999-06-28'
LastModified: '2000-02-13'
Severity: SER
Status: Released
Submitter: techsupp
ChangedBy: hobbs
OS: Other
OSVersion: BSD/OS 4.0.1
Machine: NA
FixedDate: '2000-02-13'
FixedInVersion: 8.3b1
ClosedDate: '2000-10-25'


Name:

Steven M. Schultz


Comments:

The following is the output from "make test" - it ceased running

(sleeping on

select()) after the "Running http 1.0 tests in slave interp" output.


    Tcl 8.1.1 tests running in interp:  /packages/tcl8.1.1/unix/tcltest

    Tests running in working dir:  /packages/tcl8.1.1/unix

    Tests began at Fri Jun 25 11:10:39 PDT 1999

...

    event.test


    ==== event-1.1 Tcl_CreateFileHandler, reading FAILED

    ==== Contents of test case:


        testfilehandler close

        testfilehandler create 0 readable off

        testfilehandler clear 0

        testfilehandler oneevent

        set result ""

        lappend result [testfilehandler counts 0]

        testfilehandler fillpartial 0

        testfilehandler oneevent

        lappend result [testfilehandler counts 0]

        testfilehandler oneevent

        lappend result [testfilehandler counts 0]

        testfilehandler close

        set result


    ---- Result was:

    {1 0} {2 0} {3 0}

    ---- Result should have been:

    {0 0} {1 0} {2 0}

    ==== event-1.1 FAILED


    exec.test

....


ReproducibleScript:

On a BSD/OS 4.0.1 system running ./configure --enable-threads produces a

tcltest

program that crashes.   Also, in BSD/OS the threads routines are located

in libc rather than a separate pthreads library.


After applying the patch below ./configure correctly finds the pthreads

routines, tcltest does not crash.   However numerous tests fail (but

work if threads are not enabled)


The problem is that the initial stack size for newly created threads is

too small.  NOTE:  this is likely not a directly suitable patch for the

distribution

because the stack limit should be configureable from the ./configure

scrip _AND_

it does not set the stack size for the primary thread (is that strictly 

necessary?  I don't know).


ObservedBehavior:

tcltest crashes if --enable-threads is given.  The patch below fixes

that problem but then other tests fail.  Also, with threads enabled the

"http" test

hangs (process goes to sleep and never wakes up) immediately after

"Running http 1.0 tests in slave interp"


DesiredBehavior:

Successful test completion? ;-) ;-)   I have no idea if other tests fail

because execution seems to cease after the httpd tests.


This is on a SMP (dual PPro) system.  I will try the tests on a

Uniprocessor

system in the future (probably after coming back from vacation) and see

if the behaviour changes.


Obviously it is entirely possible the thread related problems are a BSD/OS

problem.   Usually however if a program successfully compiles and links

it runs well.


Patch:

*** configure.in.dist   Wed May 26 16:47:27 1999

--- configure.in        Thu Jun 24 21:30:25 1999

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

*** 42,48 ****

       # The space is needed

       THREADS_LIBS=" -lpthread"

    else

!      AC_MSG_WARN("Don t know how to find pthread lib on your system - you must disable thread support or edit the LIBS in the Makefile...")

    fi

  else

    AC_MSG_RESULT(Will compile without Threads support (normal))

--- 42,52 ----

       # The space is needed

       THREADS_LIBS=" -lpthread"

    else

!     AC_CHECK_LIB(c,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)

!     if test "$tcl_ok" = "yes"; then

!     else

!       AC_MSG_WARN("Don t know how to find pthread lib on your system - you must disable thread support or edit the LIBS in the Makefile...")

!     fi

    fi

  else

    AC_MSG_RESULT(Will compile without Threads support (normal))

*** tclUnixThrd.c.dist  Fri Apr 16 14:02:09 1999

--- tclUnixThrd.c       Thu Jun 24 21:48:42 1999

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

*** 74,79 ****

--- 74,80 ----

      pthread_attr_t attr;


      pthread_attr_init(&attr);

+     pthread_attr_setstacksize(&attr, 256*1024);

      pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);

      if (pthread_create((pthread_t *)idPtr, &attr, (void * (*)())proc, (void *)clientData) < 0) {

        return TCL_ERROR;


PatchFiles:

tclUnixThrd.c

    configure.in




A fix was made on 10/19/1999 to the unix notifier to fix the
test problems mentioned.  We still need to look at fixing the
config stuff for BSD/OS4. 
-- 10/21/1999 hobbs
Stack space problem still outstanding - another solution is
being looked into besides just setting it really big.  8.2.2
has a regexp engine that uses much less stack.  tcl.m4 has been
adjusted for 8.3 to look for pthread_mutex_init in libc as well. 
-- 11/10/1999 hobbs
Appears that BSD/OS may have a more peculiar/picky threading
model for pthreads that needs to be looked in to. 
-- 11/18/1999 hobbs
This turns out to have been a BSD/OS threads bug. 
-- 02/13/2000 hobbs