Subject: Re: CCL:malloc etc. on DEC Alpha

From: [email-masked] (Hinsen Konrad)
Date: Thu, 16 Mar 95 10:03:19 -0500

I am finding in using 'malloc' family or routines[malloc, free etc.] on our DEC
   alpha machines running OSF/1. whenever they are called the program gives
   segmentaion fault or memory fault and aborts. The code works very fine on other
   machines. These are veru eesential in many huge comp. chem programs where
   memory need to allocated as needed rather than fixed arrays and i can not
   change the developed code for it is pain as well as not usefull.

There might be a bug in DEC's version of malloc(), but that is highly
improbable - malloc() is a very fundamental routine for many Unix programs,
and quite old, so bugs should have been found long ago. You might try
to link with the compiler option -lmalloc (available on many Unix
machines, but I am not sure about the Alphas), which simply
replaces malloc() by a different version, optimized for speed rather
than memory space.

However, in all cases of malloc()-related crashes I have experienced
so far (and that is a large number), the code calling malloc() was at
fault. The most typical bug is memory access beyond the allocated space.
Some versions of malloc() are quite forgiving if only a few more
bytes are used, which is often the case, and this explains why such
programs work on some machines but not on others. Another common 
way to ruin malloc's data space is to work with undefined addresses
(bad pointers in C, or wrong number of subroutine parameters in Fortran).

My recommendation is not to use programs that crash in malloc().
Even if they work on some machines, they are essentially buggy
and not to be trusted - even if they don't crash they might
produce wrong results. I know that often nothing else is
available, but in my opinion an unreliable program is no better
than no program at all.

-------------------------------------------------------------------------------
Konrad Hinsen                     | E-Mail: [email-masked]
Departement de chimie             | Tel.: +1-514-343-6111 ext. 3953
Universite de Montreal            | Fax:  +1-514-343-7586
C.P. 6128, succ. A                | Deutsch/Esperanto/English/Nederlands/
Montreal (QC) H3C 3J7             | Francais (phase experimentale)
-------------------------------------------------------------------------------