Re: segfaults in mm_malloc

From: David Kunzman (
Date: Tue Jun 28 2005 - 12:29:01 CDT

There does not seem to be a prototype for this function (and a few
others). As a result, the compiler is assuming the return type of the
function is an "int". When the compiler (icc in the case we were
looking at) does the cast, it tries to convert the "int" that was
returned (which is really a 64-bit pointer) into a "char*". Since the
compiler "thinks" the returned value is only 32-bits, it is sign-extends
the 32-bit value to fit the 64-bit register which wipes out the upper
32-bits of the pointer making it invalid. A fix should be checked in soon.

Dave Kunzman

Brian Bennion wrote:

>Hi Tim,
>I saw your posting on the namd wiki and want you to know that I to have
>seen this problem or one very similar in mm_mallac. David Kunzman
>(charm++ developer) worked on it for a couple of days last week.
>I do not know what the final results were, other than the compiler makes
>some default assumptions about casting a void * to a char *. It instead
>casts it to an int and wipes out half of the memory address. So what is
>actually returned is entirely bogus.
>What compiler are you using?
> ************************************************
> Brian Bennion, Ph.D.
> Bioscience Directorate
> Lawrence Livermore National Laboratory
> P.O. Box 808, L-448
> 7000 East Avenue phone: (925) 422-5722
> Livermore, CA 94550 fax: (925) 424-6605

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:39:38 CST