RE: [Scalex86 - linux] FW: segfaults in mm_malloc

From: Tim Sirianni (tim_at_scalemp.com)
Date: Thu Jun 30 2005 - 18:20:44 CDT

Brian and Dave,

Thanks for your replies.

I understand what you're saying, but I fear it applies to 64-address-bit
systems with 32-bit integers (e.g., Itanium). Since I'm running on an x86
system where sizeof(void *) == sizeof(int), I don't think that missing
prototypes could be the cause of this problem. Plus, I see the SIGSEGVs
only occasionally - maybe one run in 3 fails.

I've used both icc and gcc and see the problem with either compiler.

Maybe I've misunderstood what you were trying to tell me, please correct me
if so.

Thanks,
Tim

-----Original Message-----
From: David Kunzman <kunzman2_at_uiuc.edu>
To: Brian Bennion <brian_at_youkai.llnl.gov>
CC: tim_at_scalex86.org <tim_at_scalex86.org>; namd-l_at_ks.uiuc.edu
<namd-l_at_ks.uiuc.edu>
Sent: Tue Jun 28 13:29:01 2005
Subject: Re: segfaults in mm_malloc

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
>
>
> ************************************************
> Brian Bennion, Ph.D.
> Bioscience Directorate
> Lawrence Livermore National Laboratory
> P.O. Box 808, L-448 bennion1_at_llnl.gov
> 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:40:55 CST