| Anonymous | Login | Signup for a new account | 11-10-2008 11:04 PST |
| Main | My View | View Issues | Change Log | Docs |
| Viewing Issue Simple Details [ Jump to Notes ] | [ View Advanced ] [ Issue History ] [ Print ] | |||||||||||
| ID | Category | Severity | Reproducibility | Date Submitted | Last Update | |||||||
| 0000972 | [uClibc] Posix Threads | minor | always | 07-27-06 05:36 | 10-12-08 14:02 | |||||||
| Reporter | bsfost | View Status | public | |||||||||
| Assigned To | uClibc | |||||||||||
| Priority | normal | Resolution | open | |||||||||
| Status | assigned | Product Version | 0.9.28 | |||||||||
| Summary | 0000972: errno broken in linuxthreads.old | |||||||||||
| Description |
I have a problem where, effectively, errno is never set in threads within applications built with uClibc (using the linuxthreads.old library). Debugging has shown that the system call (send(), in the case of the example) is made and the global/libc errno is set prior to returning to application code. The subsequent request to retrieve the error code calls into __errno_location() in the linuxthreads.old library, which finds the appropriate thread descriptor and returns (*self->p_errnop), which was never set. I didn't see anything obvious that "intended" to set the thread specific errno value based on system calls made on that thread's behalf (i.e., I would expect this in the syscall wrappers, perhaps..?), but I'm fairly new to this library so I'm not sure whether this is considered a bug, misconfiguration or simple lack of functionality. For completeness, I compared the behavior with an _old_ glibc-2.2 system which looked like it had the same general design. The application worked in this case, but I noticed that the thread_self() call (while requesting the errno value in the thread, following the failed syscall) ended up returning a pointer to the __pthread_initial_thread structure rather than the specific thread structure I assume it created when it cloned (which is what happens in uClibc's thread_self()). I also tested a quick change in uClibc by setting __pthread_manager_thread's p_errnop to '&_errno' as well as new threads created in pthread_handle_create(). This change allowed expected behavior, but it's probably not the appropriate fix. Any information on this is greatly appreciated, and let me know if I've been unclear or missed any important points. Thanks. Brian |
|||||||||||
| Additional Information |
The following code demonstrates the problem, tested with uClibc for arm and x86. It expects a "bad file descriptor" error from the send() call, but the errno value remains 0 within the thread. ------- #include <stdio.h> #include <errno.h> #include <pthread.h> void *test(void *data); void error_test(); int main() { pthread_t tid; if (pthread_create(&tid, NULL, test, NULL) < 0) printf("error creating thread\n"); pthread_join(tid, NULL); error_test(); return 0; } void *test(void *data) { error_test(); } void error_test() { if (send(23, NULL, 0) < 0) { printf("send(): %d (%p): %s\n", errno, &errno, strerror(errno)); } } ---------------------------------------------- |
|||||||||||
| Attached Files |
|
|||||||||||
|
|
||||||||||||
| Copyright © 2000 - 2006 Mantis Group |