Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
* Thread safe malloc in Tru64?
@ 2003-11-20 14:11 Ioannis E. Venetis
  2003-11-20 16:30 ` Jerry Feldman
  2003-11-21 13:16 ` David Butenhof
  0 siblings, 2 replies; 4+ messages in thread
From: Ioannis E. Venetis @ 2003-11-20 14:11 UTC (permalink / raw)


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




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-11-25 16:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-20 14:11 Thread safe malloc in Tru64? Ioannis E. Venetis
2003-11-20 16:30 ` Jerry Feldman
2003-11-21 13:16 ` David Butenhof
2003-11-25 16:16   ` Ioannis E. Venetis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox