Quantcast

statically linked pthread library crashes program

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

statically linked pthread library crashes program

Flex Flextrometer
I'm using MinGW 5.1.6 with MSYS 1.0.11 to create an application that utilizes pthreads. The pthread library I am using comes from http://sourceware.org/pthreads-win32/. I understand that this is the most common one used under MinGW. I managed to compile the pthread library and link against it, but when the program runs, it crashes. The program I am compiling is the first sample source from a tutorial http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html. I've compiled it on Linux and it ran fine.

Here are the steps I took:
* Compiled the pthreads library using 'make clean GC-static' command. I ran the test inside tests/ and it passed.

* Copied libpthreadGC2.a, pthread.h, sched.h, and sempahore.h to my local source tree.

* Executed the following gcc commands
   gcc -g -UNDEBUG -Wall -D__CLEANUP_C -DPTW32_STATIC_LIB -o main.exe main.c
   -Iinclude -Llib -lpthreadGC2 -lsupc++ -lws2_32

  This is the command that was executed during the test in tests/.

* Ran the program and crashed if it reaches a call to pthread_create().

I tried this on two machines and the result is the same. I haven't installed any other pthread library, so I don't think there's a conflict there.

Thank you.

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: statically linked pthread library crashes program

Eran Ifrah
On 12/31/2009 7:04 AM, Flex Flextrometer wrote:

> Here are the steps I took:
> * Compiled the pthreads library using 'make clean GC-static' command.
> I ran the test inside tests/ and it passed.
>
> * Copied libpthreadGC2.a, pthread.h, sched.h, and sempahore.h to my
> local source tree.
>
> * Executed the following gcc commands
>    gcc -g -UNDEBUG -Wall -D__CLEANUP_C -DPTW32_STATIC_LIB -o main.exe
> main.c
>    -Iinclude -Llib -lpthreadGC2 -lsupc++ -lws2_32
>
>   This is the command that was executed during the test in tests/.
>
> * Ran the program and crashed if it reaches a call to pthread_create().
I am using pthread myself using the latest MinGW release from
sourceforge (gcc4.4.0)
For me it is working great. However, note that I did not had to download
any other libraries other than
the ones offered in the MinGW download site.

In addition to the GCC 4, I also downloaded this targz:

https://sourceforge.net/projects/mingw/files/GCC%20Version%204/Current%20Release_%20gcc-4.4.0/pthreads-w32-2.8.0-mingw32-dll.tar.gz/download

And simply extracted its content to my MinGW directory.

Building sample:

gcc -c  "C:/TestArea/pthread_sample/main.c" -g  -o ./Debug/main.o "-I."
gcc -o ./Debug/pthread_sample ./Debug/main.o  "-L."  -lpthread

Note that I am linking against 'pthread' and not against 'pthread*GC2*'

And this sample runs fine.
Eran



------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: statically linked pthread library crashes program

Tor Lillqvist
In reply to this post by Flex Flextrometer
It doesn't seem to be very well documented, but you need to call
ptw32_processInitialize() before any other pthreads-win32 call if you
use a static pthreads-win32 library.

It is only mentioned once in the README file and is quite easy to miss
as it is mentioned under a "Other name changes" header (the function
apparently used to be called _pthread_processInitialize() a long time
ago).

--tml

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: statically linked pthread library crashes program

Tor Lillqvist
In reply to this post by Eran Ifrah
> In addition to the GCC 4, I also downloaded this targz:
>
> https://sourceforge.net/projects/mingw/files/GCC%20Version%204/Current%20Release_%20gcc-4.4.0/pthreads-w32-2.8.0-mingw32-dll.tar.gz/download

The thread is about using a *static* pthread library. The above
tarball contains an import library for pthreadGC2.dll (which you
apparently already had in your PATH from earlier. Check with objdump
-p and you will notice that the executable you built links to
pthreadGC2.dll.

--tml

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: statically linked pthread library crashes program

Flex Flextrometer
Thank you. The solution was to include ptw32_processInitialize() before any pthread call.

On Thu, Dec 31, 2009 at 3:45 AM, Tor Lillqvist <[hidden email]> wrote:
The thread is about using a *static* pthread library. The above
tarball contains an import library for pthreadGC2.dll (which you
apparently already had in your PATH from earlier. Check with objdump
-p and you will notice that the executable you built links to
pthreadGC2.dll.

--tml

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Loading...