# Re[6]: [Gc] FW: MinGW/msys on Windows 32 and 64 bit using pthreads-win32

Ivan Maidanski ivmai at mail.ru
Sat Jun 16 05:17:47 PDT 2012

Hi Eduard,

Sat, 16 Jun 2012 14:08:22 +0200 Eduard Urbach <e.urbach at googlemail.com>:
> Hi Ivan,
>
> thanks for fixing test_cpp. It seems the problem with 7.2 is not the
> configure script but the fact that thread_leak_test somehow uses Win32
> threads because GC_PTHREADS is not defined in the C file. Therefore I get
> this error message on make check:
>
> *However* make and make install worked and I just tested the new .a / .dll
> files in my application. The app crashed but the problem was that I used
> "-static-libgcc -static-libstdc++" on Windows. So I disabled static linking
> and the 7.2 pthread-win32 binaries seem to work fine so far (on a 32 bit
> system). I guess they will fail at GetThreadContext() on Win64 though.
>
> I am using USE_LIBC_PRIVATE when compiling by the way.

Any patch (simplifying the build, fixing some bug or adding some useful functionality) is, of course, welcomed.

Regards,
Ivan

>
> tl;dr: 7.2 posix works now on Win32 but "make check" fails because of
> thread_leak_test.c. For Win64 I still don't know any solutions.
>
> Regards,
> Eduard
>
> On Sat, Jun 16, 2012 at 12:21 PM, Ivan Maidanski <ivmai at mail.ru> wrote:
>
> > Hi Eduard,
> >
> > I've fixed the issue in test_cpp in master branch -
> >
> https://github.com/ivmai/bdwgc/commit/a7fdbdb9c409b6bf4ee3195c55fb514cf788b3c6
> > (I'll cherry-pick this commit to gc-7.2x release later.)
> >
> > Regarding MinGW+pthreads-w32 (32-bit): I haven't launched configure but
> > I've compiled and launched several tests manually (7.3alpha3 snapshot),
> > e.g.:
> > C:\mingw-w32\bin\i686-w64-mingw32-gcc -I include -I libatomic_ops/src -O2
> > -Wall -Wextra -I pthreads-w32-2-9-1-release tests/test.c extra/gc.c
> >
> > Could you provide me with the configure error log for MinGW+pthreads-w32?
> >
> > Regards,
> > Ivan
> >
> > Fri, 15 Jun 2012 15:00:56 +0200 Eduard Urbach <e.urbach at googlemail.com>:
> > > Hi Ivan,
> > >
> > > test_cpp.exe crashed on 7.2b, the other 10 tests passed:
> > >
> >
> > >
> > >
> > > Regards,
> > > Eduard
> > >
> > > On Fri, Jun 15, 2012 at 8:37 AM, Ivan Maidanski <ivmai at mail.ru> wrote:
> > >
> > > > Hi Eduard,
> > > >
> > > > What's about threads=win32 for Win64? (I have tried only test.c for
> > some
> > > > gc7.2alpha snapshot for Win64)
> > > >
> > > > I can't access Win64 right now but I tested gc7.3alpha using mingw32
> > (with
> > > > Win32 threads model):
> > > > C:\mingw-w32\bin\i686-w64-mingw32-gcc -O2 -fno-strict-aliasing
> > > > -DALL_INTERIOR_POINTERS -DGC_GCJ_SUPPORT -DGC_THREADS
> > > > -DPARALLEL_MARK -DDONT_USE_USER32_DLL -I include -I libatomic_ops/src
> > -s
> > > > -Wall -Wextra tests/thread_leak_test.c extra/gc.c
> > > >
> > > > Cygwin (32-bit, posix threads) also passes this test.
> > > >
> > > > Regards,
> > > > Ivan
> > > >
> > > > Thu, 14 Jun 2012 13:59:03 +0200 Eduard Urbach <e.urbach at googlemail.com
> > >:
> > > > > Has anyone had success building the GC with MinGW 64 then?
> > > > >
> > > > > Using GCC 4.6 with threads = posix and x86_64-w64-mingw32 host the
> > > > > following tests fail:
> > > > >
> > > > > threadleaktest.exe
> > > > > test_cpp.exe
> > > > >
> > > > > On 32-bit systems with an absolutely normal MinGW 32 installation
> > 14/15
> > > > > pass, but this one fails again:
> > > > >
> > > > > threadleaktest.exe
> > > > >
> > > > > I can't build gc7.3alpha2 to create 32 or 64 bit Windows binaries
> > (well
> > > > the
> > > > > 32 bit one works on x86 but threakleadtest.exe still fails), is there
> > > > > another solution to this problem - maybe another version?
> > > > >
> > > > > On Tue, Jun 12, 2012 at 4:51 PM, Bruce Mitchener
> > > > > <bruce.mitchener at gmail.com>wrote:
> > > > >
> > > > > > I've not seen a workaround for this on Windows XP or Vista apart
> > from
> > > > > > shipping a separate 64 bit build. It is my understanding that this
> > bug
> > > > in
> > > > > > WoW64 has been fixed in Windows 8.  As long as you're calling
> > > > > > GetThreadContext in a 32 bit app on 64 bit Windows prior to
> > Windows 8,
> > > > you
> > > > > > will experience problems.
> > > > > >
> > > > > >  - Bruce
> > > > > >
> > > > > > On Tue, Jun 12, 2012 at 9:05 PM, Boehm, Hans <hans.boehm at hp.com>
> > > > wrote:
> > > > > >
> > > > > >>  Forwarding, since I’m travelling , and can’t easily approve
> > this.****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> Hans****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> *From:* Eduard Urbach [mailto:e.urbach at googlemail.com]
> > > > > >>
> > > > > >> ****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> Hello,****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> I've been using Boehm GC successfully under Linux/Debian systems
> > and I
> > > > > >> thought the Windows versions was working as well until I tried it
> > on
> > > > 64 bit
> > > > > >> systems. I am using these options:****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> ./configure --enable-cplusplus --enable-threads=posix
> > > > > >> --enable-thread-local-alloc --enable-parallel-mark****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> Before including the GC:****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >>             #ifdef _WIN32****
> > > > > >>
> > > > > >>                         #define GC_WIN32_PTHREADS****
> > > > > >>
> > > > > >>             #else****
> > > > > >>
> > > > > >>                         #define GC_THREADS****
> > > > > >>
> > > > > >>             #endif****
> > > > > >>
> > > > > >>             ****
> > > > > >>
> > > > > >>             #define GC_OPERATOR_NEW_ARRAY****
> > > > > >>
> > > > > >>             #define PARALLEL_MARK****
> > > > > >>
> > > > > >>             #define USE_LIBC_PRIVATE****
> > > > > >>
> > > > > >>             ****
> > > > > >>
> > > > > >>             // PThreads****
> > > > > >>
> > > > > >>             #ifndef _REENTRANT****
> > > > > >>
> > > > > >>                         #define _REENTRANT****
> > > > > >>
> > > > > >>             #endif****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >>             #ifndef _MULTI_THREADED****
> > > > > >>
> > > > > >>                         #define _MULTI_THREADED****
> > > > > >>
> > > > > >>             #endif****
> > > > > >>
> > > > > >>             ****
> > > > > >>
> > > > > >>             #ifdef _WIN32****
> > > > > >>
> > > > > >>                         #include "../gc-7.3/gc_cpp.h"****
> > > > > >>
> > > > > >>             #else****
> > > > > >>
> > > > > >>                         #include "../gc/gc_cpp.h"****
> > > > > >>
> > > > > >>             #endif****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> I wrote a program which creates 4 threads where each thread
> > creates a
> > > > lot
> > > > > >> of objects, if you want to test it you can download it here:
> > bp.Compiler.Benchmark
> > > > in
> > > > > >> multithreaded mode.****
> > > > > >>
> > > > > >> On Win64 when I run it in multithreaded mode I get a message box
> > > > saying
> > > > > >> GetThreadContext() failed. A quick google search showed me I'm not
> > > > the only
> > > > > >> one having this problem and it seems to be related to WOW64.****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> Compiling the GC with different configure options and compilers
> > gave
> > > > the
> > > > > >> following results:****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >>
> > > > >
> > > >
> >
> ---------------------------------------------------------------------------------------------------------
> > > > > >> ****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> MinGW 32, GCC 4.6, Threads = win32, 64-bit host system, GC
> > > > 7.3alpha2****
> > > > > >>
> > > > > >>  --> gctest crashes, rest works****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> MinGW 32, GCC 4.7, Threads = win32, 64-bit host system, GC
> > > > 7.3alpha2****
> > > > > >>
> > > > > >>  --> 3 tests fail, rest works (all threading related tests iirc,
> > e.g.
> > > > > >> threadleaks)****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> MinGW 64, GCC 4.7, Threads = posix, 64-bit host system, GC
> > > > 7.3alpha2****
> > > > > >>
> > > > > >>  --> Compile error (sorry for not having saved it...)****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >>
> > > > > >>
> > > > >
> > > >
> >
> ---------------------------------------------------------------------------------------------------------
> > > > > >> ****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> MinGW 32, GCC 4.6, Threads = win32, 32-bit host system, GC 7.2
> > ****
> > > > > >>
> > > > > >>  --> all tests pass, however I need pthreads-win32****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> MinGW 32, GCC 4.6, Threads = posix, 32-bit host system, GC 7.2
> > ****
> > > > > >>
> > > > > >>  --> Configure fails, can't get it to use pthreads-win32****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> MinGW 32, GCC 4.6, Threads = posix, 32-bit host system, GC
> > > > 7.3alpha2****
> > > > > >>
> > > > > >>  --> 1 test fails (threadleaks crashes) but my multithreaded test
> > > > > >> application is running fine****
> > > > > >>
> > > > > >>  --> The same application run on 64-bit Windows leads to a
> > message box
> > > > > >> saying GetThreadContext() failed****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >>
> > > > >
> > > >
> >
> ---------------------------------------------------------------------------------------------------------
> > > > > >> ****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> Basically I am trying to find a way to get the GC running with
> > > > > >> pthreads-win32 on 32- and 64-Bit Windows using either MinGW 32 or
> > > > MinGW 64,
> > > > > >> whatever works. I am not really interested in building native
> > 64-bit
> > > > > >> binaries for Windows but I want my 32-bit applications to run
> > > > normally on a
> > > > > >> 64-bit system.****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> I am willing to help out if you need more information, I have a
> > 32-
> > > > and
> > > > > >> 64-bit Windows system running and both lead to at least 1 test
> > > > failing on
> > > > > >> make check. On Debian/Ubuntu everything works fine, though :)****
> > > > > >>
> > > > > >> ** **
> > > > > >>
> > > > > >> Regards,****
> > > > > >>
> > > > > >> Eduard Urbach****
> > > > > >>
> > > > > >> _______________________________________________
> > > > > >> Gc mailing list
> > > > > >> Gc at linux.hpl.hp.com
> > > > > >> https://www.hpl.hp.com/hosted/linux/mail-archives/gc/
> > > > > >>
> > > > > >
> > > > > >
> > > >
> > > >
> > >
> > >
> >