Tcl Source Code

View Ticket
Login
Ticket UUID: 415131
Title: multithreaded tclsh exec fails (FreeBSD)
Type: Bug Version: None
Submitter: mad_derf Created on: 2001-04-10 12:38:11
Subsystem: 49. Threading Assigned To: hobbs
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2001-10-18 07:57:11
Resolution: Fixed Closed By: hobbs
    Closed on: 2001-10-18 00:57:11
Description:
Hi all,

I have been trying to use the tclsh8.1_r on a FreeBSD
host (it was the only available precompiled package,
but I also had the case with Tcl 8.0 and Tcl 8.3.2
compiled).

Ok, so here is the problem :

% exec ls
error reading output from command: interrupted system
call
%

When I link tclsh with libc.so rather than libc_r.so
(the multi-threaded c library), there is no problem,
but if I link with the libc_r.so, I often have the
above output (I say often, because it also sometimes
work ...)

I went into the code (and I had to say it was tough
with GDB - seems to have problem with multi-threaded
applications on FreeBSD), and it seems to be coming
from the unix/tclUnixPipe.c file.

In the PipeInputProc (), I replaced :

------------

    bytesRead = read(GetFd(psPtr->inFile), buf,
(size_t) toRead);
    if (bytesRead > -1) {
        return bytesRead;
    }
    *errorCodePtr = errno;
    return -1;

------------

with

------------

    do
{
bytesRead = read(GetFd(psPtr->inFile), buf, (size_t)
toRead);
} while ((bytesRead < 0) && (errno == EINTR));

    if (bytesRead < 0)
{
*errorCodePtr = errno;
return (-1);
}
    else
{
return (bytesRead);
}
-------------

It seems that the SUN RPCs also use that trick (in
clnt_udp.c). After applying that patch, it seems all
right.

Shall I commit somewhere for that patch to be
integrated (if agreed) in next releases ?

Hope this helps

DERF
User Comments: hobbs added on 2001-10-18 07:57:11:
Logged In: YES 
user_id=72656

Testing threaded and non-threaded on HP-UX 11, Sol-2.6 and 
Linux (RH6.2 and 7.0) and it seems to pass all tests.  
Applied to 8.3.4cvs and 8.4a4cvs.

andreas_kupries added on 2001-10-04 23:32:54:
Logged In: YES 
user_id=75003

Note the possibly related items
218076, 218120, 219251, and 219354.

dgp added on 2001-10-04 23:20:57:
Logged In: YES 
user_id=80530

Jeff, here's a FreeBSD fix that should go into 8.3.4.

mad_derf added on 2001-05-18 00:26:17:

File Added - 6390: patchfile

mad_derf added on 2001-05-18 00:26:16:
Logged In: YES 
user_id=193026

I have created the patch file for that bug. It should be
attached below (hmmm, not sure yet, it is the first time I
do that).

I ran the make test on several architectures (linux, solaris
and FreeBSD), there was no differentces with my changes
except for the multithreaded version on FreeBSD. It now
works almost fine ... but I guess no one ever tested it
multithreaded on FreeBSD :)

So now, most of the test goes on with multithread. Almost no
more "interrupted system call". Seems good no ?

Ok, now here is the patch

hobbs added on 2001-05-04 03:50:56:
Logged In: YES 
user_id=72656

Please create the necessary patch and add it to this report 
or place it in the Patches area for other to test on other 
systems.  Also make sure that this passes 'make test' on 
your system (both with threaded and non-threaded builds).

Attachments: