NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
thread-stub related query
Hi,
With respect to the below issue, i have one question.
Is it required for the stub functions to send SIGABRT signal as below:
$ cat thread-stub.c
:
#define DIE() (void)kill(getpid(), SIGABRT)
#define CHECK_NOT_THREADED_ALWAYS() \
do { \
if (__isthreaded) \
DIE(); \
} while (/*CONSTCOND*/0)
#if 1
#define CHECK_NOT_THREADED() CHECK_NOT_THREADED_ALWAYS()
#else
#define CHECK_NOT_THREADED() /* nothing */
#endif
:
For eg:
All the below functions in thread-stub
__libc_mutex_init()
__libc_mutex_lock()
__libc_mutex_trylock()
__libc_mutex_unlock()
__libc_mutex_destroy()
Send SIGABRT signal when __isthreaded is set.
Is there any specification for thread-stub functionality.
Is it ok to just return from stub functions instead of aborting.
Could any one help me in this regard?
Awaiting for your reply
Thanks & Regards,
Channa
---------- Forwarded message ----------
From: Channa <channa.kad%gmail.com@localhost>
Date: 2009/6/29
Subject: issue with thread-stub
To: netbsd-users%netbsd.org@localhost
Hi,
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("libxx.so", RTLD_NOW);
dlclose(handle);
}
6. When i run this test
$ ./a.out
Aborted
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
abort.
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() CHECK_NOT_THREADED_ALWAYS()
#else
#define CHECK_NOT_THREADED() /* nothing */
#endif
:
I mean just ignore instead of sending SIGABRT? Will this be OK?
Waiting for your reply.
Thanks & Regards,
Channa
Home |
Main Index |
Thread Index |
Old Index