[Trilinos-Users] Memory allocation problem in ML on win64

Raymond Tuminaro rstumin at sandia.gov
Thu Jul 7 14:54:09 MDT 2011


Charles,
   I think you have accurately diagnosed the situation. I stared at the code for a while ... and using ml_size_t seems 
like a reasonable fix. I've made this modification, ran some quick tests, and have checked something into the 
repository. We'll see how the changes fair with the regression tests across a variety of platforms.

-Ray


Charles Boivin wrote:
> Is this the correct mailing list for ML problems/discussions? If not, let me know, I'll re-address the issue over there.
> 
> I think I have found a (serious?) problem in ML's memory allocation routine on win64. In
> ML_memory_alloc() (file ml_memory.c), we have the following bit of code (I am assuming this is putting 'markers' at either end of the newly allocated memory block for error-checking purposes?)
> 
> ***
>       if ( i < MAX_MALLOC_LOG )
>       {
>          int_ptr    = (int *) var_ptr;
>          (*int_ptr) = i + 1;
>          int_ptr    = (int*) ((long) var_ptr + nchunks*ndouble - ndouble);
>          (*int_ptr) = i + 1;
>          ...
> ***
> 
> The problem is with the use of the (long) cast; on win64, a 'long' is a signed 32-bit integer. If var_ptr happens to reside in a memory region with an address >2GB, the cast to long will result in a negative integer, and mayhem will ensue (or in the particular case that I was tracking down, the code will simply crash on the following line).
> 
> I have noticed that ml_memory.h a 'ml_size_t' type is defined; it maps to size_t if defined, or to an int if not. Now, size_t on win64 is an unsigned 64-bit integer (which I assume is what we'd want), but I would think that mapping to int is definitely NOT what we want (at least for win64, it's not). Shouldn't unsigned integers be used? For my tests, I used 'unsigned long long', which is 64-bit, but I don't know if this would fly for all platforms.
> 
> By then replacing all (long) casts to (ml_size_t) in ml_memory.c, I was able to successfully use the ML_Preconditioner class for my problem. However, I have no idea if my modifications are appropriate for all platforms, or if they could cause other unseen problems in ML. What is clear, however, is that using (long) is problematic in this case.
> 
> Is it possible to get some advice on the best possible way to fix this?
> 
> Thank you.
> 
> 
> Charles Boivin
> MAYA Heat Transfer Technologies Ltd. 
> 
> _______________________________________________
> Trilinos-Users mailing list
> Trilinos-Users at software.sandia.gov
> http://software.sandia.gov/mailman/listinfo/trilinos-users

-- 
Ray Tuminaro                      phone: (925) 294-2564
MS 9159                           fax:   (925) 294-2234
Sandia National Laboratories      email: rstumin at sandia.gov
PO Box 969                        http://www.cs.sandia.gov/~rstumin
Livermore, CA 94551




More information about the Trilinos-Users mailing list