BusyBox Bug and Patch Tracking
BusyBox
  

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  main3.c [^] (983 bytes) 08-23-07 17:18
 pthread-errno.patch [^] (18,038 bytes) 10-19-07 12:09

- Relationships

- Notes
(0002680)
andre_rosa
08-23-07 17:19

The attached file has different behavior in mipsel platform when comparing with glibc in a regular PC.
 
(0002834)
corp186
10-19-07 11:15

This appears to be fixed by revision 15936. I have applied the diff from 15935 to 15936 to the sources I saw this bug with and it fixed the issue for me.
 
(0002835)
andre_rosa
10-19-07 11:33

Hi, Mr. corp186.

     Would you please post the aforementioned patch?

Thank you so much!
 
(0002836)
corp186
10-19-07 12:09

You can get the patch from "svn diff -r 15935:15936" inside the uClibc sources. I have attached the patch as well.
 
(0002842)
andre_rosa
10-19-07 13:00

Thanks a lot for your help!
I do not use SVN at this moment to track uClibc development.
 
(0013394)
bernhardf
10-12-08 14:02

Sounds like this is fixed.
 

- Issue History
Date Modified Username Field Change
07-27-06 05:36 bsfost New Issue
07-27-06 05:36 bsfost Status new => assigned
07-27-06 05:36 bsfost Assigned To  => uClibc
08-23-07 17:11 andre_rosa Issue Monitored: andre_rosa
08-23-07 17:18 andre_rosa File Added: main3.c
08-23-07 17:19 andre_rosa Note Added: 0002680
10-19-07 11:15 corp186 Note Added: 0002834
10-19-07 11:33 andre_rosa Note Added: 0002835
10-19-07 12:09 corp186 File Added: pthread-errno.patch
10-19-07 12:09 corp186 Note Added: 0002836
10-19-07 13:00 andre_rosa Note Added: 0002842
10-12-08 14:02 bernhardf Note Added: 0013394


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker