bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: popen/pthread/static-libs bug


From: David Durham
Subject: Re: popen/pthread/static-libs bug
Date: Wed, 03 Jul 2002 09:47:13 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/00200205

Davy Durham wrote:

Hi, I've found a combination of threads, popen and linking with glibc statically which causes the application to lock up... My machine is using x86 linux-2.4.18 and glibc-2.2.4 . I'm using mandrake.. I've tried it on a debian machine running a 2.2 kernel and also even on an alpha running linux and the problem happens there too.. I found this while trying to build a statically linked binary of my application ReZound: http://rezound.sourceforge.net

I've narrowed it down to a few source code lines which I have attached as bug.c

Basically, if you compile this as:

    gcc -o bug bug.c -lpthread

it will work., but if you compile the same thing as:

    gcc -static -o bug bug.c -lpthread

it will lock up..

Now.. if you remove either the call to popen or the call to the two thread functions it will work when gcc is given -static

(And I know the FILE * from popen needs to be closed.. but it makes no difference as the the problem happening whether I close it before the thread starts or not)

The fact that it's related to -static (which BTW tells gcc to use static libraries instead of dynamic libraries for linking) may indicate that it's just a packaging problem, or that it's related to something with dynamic library function calls.

Anyway, I hope this could be fixed soon... Even if everyone else in the world doesn't upgrade glibc, I will, so the standalone app could actually run.

Please reply to my email address because I can't find anywhere on the glibc www site to actually subscribe to this mailing list..

Thanks,
  Davy

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

#include <stdio.h>
#include <pthread.h>

void *func(void *temp)
{
        return NULL;
}

int main()
{
        pthread_t threadID;
        void *status;

        popen("ls","r");

        pthread_create(&threadID,NULL,func,NULL);
        pthread_join(threadID,&status);
        
        return 0;
}

Actually.. this source code can even be reduced to (I don't know why I had the pthread_join in there.. it hangs at the pthread_create):

#include <stdio.h>
#include <pthread.h>

void *func(void *temp)
{
        return NULL;
}

int main()
{
        pthread_t threadID;

        popen("ls","r");

        pthread_create(&threadID,NULL,func,NULL);
        
        return 0;
}







reply via email to

[Prev in Thread] Current Thread [Next in Thread]