From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,e0cdd9a132483603,start X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2003-11-20 06:11:07 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!news.belwue.de!irazu.switch.ch!switch.ch!news.grnet.gr!news.ntua.gr!not-for-mail From: "Ioannis E. Venetis" Newsgroups: comp.unix.tru64 Subject: Thread safe malloc in Tru64? Date: Thu, 20 Nov 2003 16:11:01 +0200 Organization: National Technical University of Athens, Greece Message-ID: NNTP-Posting-Host: patroclos.hpclab.ceid.upatras.gr X-Trace: ulysses.noc.ntua.gr 1069337461 89055 150.140.142.225 (20 Nov 2003 14:11:01 GMT) X-Complaints-To: usenet@ulysses.noc.ntua.gr NNTP-Posting-Date: Thu, 20 Nov 2003 14:11:01 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Xref: archiver1.google.com comp.unix.tru64:10951 Hello, I am trying to create a library that will run, among other architectures, on Tru64/Alpha systems. Of course, this library has a machine independant (the same for all architectures) and a machine dependant part. For some reasons, I chose to use the thread_create/thread_get_state/ thread_set_state/thread_resume/thread_terminate interface in the machine dependant part of the library to manage kernel-level threads on Tru64 Unix systems. I am mentioning it in case this has something to do with the problem I will describe. Now, the problem is that all my applications that use this library crash on Tru64 Unix systems (but not on other systems the library compiles on). After spending hours on debugging and inserting printf's on several places I found what was going wrong. The malloc() function, when called by all threads of the application, returns most of the time the same starting address of the allocated memory for different threads. This seems to be an issue with thread-safety of the malloc() function. I searched the Internet and found that I had to link my applications with a few libraries, in order to make them thread-safe. Some of the possibilities I found are: -lpthreads -lmach -lc_r -lpthread -lmach -lexc -lc I also tried other combinations (-lpthread -lmach -lc_r, -lpthread -lmach -lc, -lpthreads -lmach -lc,...) but none of them solved the problem. I also tried to use -D_REENTRANT and/or -D_THREAD_SAFE when compiling the library and the applications, but the problem still remains. Finally, I replaced malloc() with mmap(), and the applications run perfectly in this case, so I doubt that something else is wrong in the library. I would appreciate it if someone could give me some directions on how to link my libray and applications with thread-safe versions of all necessary libraries, both for shared and static versions. Some system specific information: OS: Compaq Tru64 UNIX V5.1 (Rev. 732) Compiler: gcc -v Reading specs from /usr/local/lib/gcc-lib/alphaev6-dec-osf4.0e/2.95.2/specs gcc version 2.95.2 19991024 (release) Thank you in advance, Ioannis E. Venetis PhD Student - Research Assistant High Performance Information Systems Laboratory Computer Engineering and Informatics Department University of Patras, Greece URL: http://www.hpclab.ceid.upatras.gr/pgroup/members/iev