On Thu, Feb 23, 2012 at 10:35:05PM -0500, Patrick Marlier wrote: > On 02/23/2012 09:34 PM, Jack Howarth wrote: >> On Thu, Feb 23, 2012 at 02:14:17PM -0500, Patrick Marlier wrote: >>> On 02/23/2012 02:04 PM, Patrick Marlier wrote: >>>> Hello, >>>> >>>> As I see in my x86_64/linux gcc build and for example recently in: >>>> http://gcc.gnu.org/ml/gcc-testresults/2012-02/msg02269.html >>>> >>>> === boehm-gc tests === >>>> Running target unix/-m32 >>>> FAIL: boehm-gc.c/thread_leak_test.c -O2 (test for excess errors) >>>> === boehm-gc Summary for unix/-m32 === >>>> Running target unix >>>> FAIL: boehm-gc.c/thread_leak_test.c -O2 (test for excess errors) >>>> >>>> due to redefinition of GC_LINUX_THREADS. >>>> >>>> Any reason why this patch was not applied? >>>> http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01903.html >>>> >>>> Thanks! >>>> -- >>>> Patrick >>> >>> Also note that the trunk boehm-gc seems to be fixed like this: >>> >>> Index: testsuite/boehm-gc.c/thread_leak_test.c >>> =================================================================== >>> --- testsuite/boehm-gc.c/thread_leak_test.c (revision 184398) >>> +++ testsuite/boehm-gc.c/thread_leak_test.c (working copy) >>> @@ -1,4 +1,7 @@ >>> -#define GC_LINUX_THREADS >>> +#ifndef GC_THREADS >>> +# define GC_THREADS >>> +#endif >>> + >>> #include "leak_detector.h" >>> #include<pthread.h> >>> #include<stdio.h> >> >> Patrick, >> This form still randomly fails on x86_64-apple-darwin11 with the >> logged output of... >> >> Setting LD_LIBRARY_PATH to >> .:/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc:/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple-darwin11.3.0/./boehm-gc/.libs:.libs:.:/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc:/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple-darwin11.3.0/./boehm-gc/.libs:.libs >> Leaked composite object at 0x10192bfe0 >> (/sw/src/fink.build/gcc47-4.7.0-1/gcc-4.7-20120223/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c:15, >> sz=4, NORMAL) >> >> Leaked composite object at 0x10192bf80 >> (/sw/src/fink.build/gcc47-4.7.0-1/gcc-4.7-20120223/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c:15, >> sz=4, NORMAL) >> >> Leaked composite object at 0x10192bfb0 >> (/sw/src/fink.build/gcc47-4.7.0-1/gcc-4.7-20120223/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c:15, >> sz=4, NORMAL) >> >> Leaked composite object at start: 0x10192bf90, appr. length: 48 >> >> when the test hangs. >> Jack > > This is another problem (related to darwin) as discussed in PR48299. > You should try the bdwgc trunk (https://github.com/ivmai/bdwgc/) and see > if the test passes. It could give a indication if it is still an > unsolved issue or not.
Patrick, The failures in the /thread_leak_test execution tests don't occur in ivmai-bdwgc-8b168d0 from upstream on darwin. The attached patch is the minimal changes which need to be backported from upstream for this test. I've left out the MS Windows specific changes from upstream but the rest seem rational to backport. Using this patch, the resulting thread_leak_test at -m64 on x86_64-apple-darwin11 never fails. Jack > > Patrick.
Index: testsuite/boehm-gc.c/thread_leak_test.c =================================================================== --- testsuite/boehm-gc.c/thread_leak_test.c (revision 184568) +++ testsuite/boehm-gc.c/thread_leak_test.c (working copy) @@ -1,13 +1,17 @@ -#define GC_LINUX_THREADS + +#ifndef GC_THREADS +# define GC_THREADS +#endif + #include "leak_detector.h" + #include <pthread.h> + #include <stdio.h> void * test(void * arg) { int *p[10]; int i; - GC_find_leak = 1; /* for new collect versions not compiled */ - /* with -DFIND_LEAK. */ for (i = 0; i < 10; ++i) { p[i] = malloc(sizeof(int)+i); } @@ -15,25 +19,53 @@ void * test(void * arg) { for (i = 1; i < 10; ++i) { free(p[i]); } -} +# ifdef GC_PTHREADS + return arg; +# else + return (DWORD)(GC_word)arg; +# endif +} #define NTHREADS 5 -int main() { +int main(void) { int i; - pthread_t t[NTHREADS]; +# ifdef GC_PTHREADS + pthread_t t[NTHREADS]; +# else + HANDLE t[NTHREADS]; + DWORD thread_id; +# endif int code; + GC_find_leak = 1; + /* with -DFIND_LEAK. */ + GC_INIT(); + for (i = 0; i < NTHREADS; ++i) { - if ((code = pthread_create(t + i, 0, test, 0)) != 0) { - printf("Thread creation failed %d\n", code); +# ifdef GC_PTHREADS + code = pthread_create(t + i, 0, test, 0); +# else + t[i] = CreateThread(NULL, 0, test, 0, 0, &thread_id); + code = t[i] != NULL ? 0 : (int)GetLastError(); +# endif + if (code != 0) { + printf("Thread creation failed %d\n", code); } } + for (i = 0; i < NTHREADS; ++i) { - if ((code = pthread_join(t[i], 0)) != 0) { - printf("Thread join failed %lu\n", code); +# ifdef GC_PTHREADS + code = pthread_join(t[i], 0); +# else + code = WaitForSingleObject(t[i], INFINITE) == WAIT_OBJECT_0 ? 0 : + (int)GetLastError(); +# endif + if (code != 0) { + printf("Thread join failed %d\n", code); } } + CHECK_LEAKS(); CHECK_LEAKS(); CHECK_LEAKS();