NetBSD-Users archive

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

issue with thread-stub


I am using the thread-stub design of NetBSD3.1 in my linux environment.
As part of this i am facing some issue mentioned below:

1. In my libc startup csu code i am initializing pthread and after the
initialization is complete i set the variable __isthreaded=1

2. When in my test which is not linked with pthread i dlopen() shared library.
  NOTE : The test is not linked with pthread. As per my requirements i
need to initialize my  pthread during csu startup, whether pthread
llibrary is lnked to the application or not.

3.The API mutex_lock() inside the dlopen() function, since pthread is
not linked it calls the thread stub function
  __libc_mutex_lock() --> CHECK_NOT_THREADED -->
CHECK_NOT_THREADED_ALWAYS -->        if (__isthreaded)   DIE(); -->
kill(getpid(), SIGABRT)

4. Because of the flow in the step 3) my program is getting aborted.

5. The test code is as below

#include <stdio.h>
#include <dlfcn.h>

int main(void)
        void *handle = dlopen("", RTLD_NOW);

6. When i run this test
 $ ./a.out

7. It is required for me to initialize pthread in the libc startup csu
routines, but setting __isthreaded should also be done at the end of
initialization routine because of which i get the SIGABRT signal,
since __isthreaded is always set in my environment(whether pthread is
used or not)

Could anyone help me how to resolved this issue?

As per my understanding the SIGABRT signal is sent since __isthreaded
is set pthread library is present, so thread-stub function should not
be called . But as per my requirements the application should not

Is it really required to send SIGABRT signal when thread-stub function
for mutex_xxxxxx() functions are called?

Or we can change the thread-stub code as below:

$ cat thread-stub.c
#if 0
#define CHECK_NOT_THREADED()    /* nothing */

I mean just ignore instead of sending SIGABRT? Will this be OK?

Waiting for your reply.

Thanks & Regards,

Home | Main Index | Thread Index | Old Index