Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: Re: [OMPI devel] 1.5rc5 has been posted
From: Larry Baker (baker_at_[hidden])
Date: 2010-08-30 20:26:02


The fix I posted in http://www.open-mpi.org/community/lists/devel/2010/08/8311.php
  for the Redefinition of symbol assert causes a link failure of
opal_wrapper. This is because there are assert() calls in opal/mca/
memory/ptmalloc2/arena.c, which is included in opal/mca/memory/
ptmalloc2/malloc.c before the conditional on MALLOC_DEBUG, which is
where I moved #include <assert.h>. arena.c does not contain its own
#include <assert.h>. I changed the patch to opal/mca/memory/ptmalloc2/
malloc.c to define assert where it was before, but in such a way that
it always uses the system <assert.h> header file to define the assert
macro.

In opal/mca/memory/ptmalloc2/malloc.c, change lines 364-369 from:

> #if MALLOC_DEBUG
> #include <assert.h>
> #else
> #undef assert
> #define assert(x) ((void)0)
> #endif

to:

> #if MALLOC_DEBUG && defined( NDEBUG )
> #error -DMALLOC_DEBUG is inconsistent with -DNDEBUG
> #endif
>
> #include <assert.h>

The reason the conditional uses the value of MALLOC_DEBUG, but
defined( NDEBUG ), is that the code that depends on MALLOC_DEBUG uses
#if MALLOC_DEBUG conditionals, while <assert.h> uses #ifdef NDEBUG to
define the assert macro. I used the same semantics to detect the
inconsistency between MALLOC_DEBUG and NDEBUG.

Larry Baker
US Geological Survey
650-329-5608
baker_at_[hidden]

On Aug 23, 2010, at 5:29 PM, Larry Baker wrote:

> The PGI C compiler complains (issues a warning) for the redefinition
> of the assert macro in opal/mca/memory/ptmalloc2/malloc.c:
>
> Making all in mca/memory/ptmalloc2
> make[2]: Entering directory `/home/baker/openmpi-1.5rc5/opal/mca/
> memory/ptmalloc2'
> CC opal_ptmalloc2_component.lo
> CC opal_ptmalloc2_munmap.lo
> CC malloc.lo
> PGC-W-0221-Redefinition of symbol assert (/usr/include/assert.h: 51)
> PGC-W-0258-Argument 1 in macro assert is not identical to previous
> definition (/usr/include/assert.h: 51)
>
> FYI. assert.h is an unusual include file -- it does not use an
> ifdef guard macro in the usual way, but undef's assert if the guard
> macro is defined (NOT if assert is defined, which is the root cause
> of this warning), define's the guard macro, then (re)define's
> assert() based on the current value of NDEBUG.
>
> opal/mca/memory/ptmalloc2/malloc.c did not change from OpenMPI
> 1.4.2. malloc.c include's opal/mca/memory/ptmalloc2/hooks.c, which
> did change in OpenMPI 1.5rc5. hooks.c indirectly include's
> <assert.h> through opal/mca/base/mca_base_param.h. This is where
> the warning occurs.
>
> malloc.c define's its own assert macro in lines 364-369:
>
> 364 #if MALLOC_DEBUG
> 365 #include <assert.h>
> 366 #else
> 367 #undef assert
> 368 #define assert(x) ((void)0)
> 369 #endif
>
> The warning occurs because the definition of assert in line 368 is
> not the same as the definition in <assert.h>:
>
> # define assert(expr) (__ASSERT_VOID_CAST (0))
>
> However, there is no reason to define assert here -- the only code
> in malloc.c that needs assert is already inside an #if !
> MALLOC_DEBUG conditional at line 2450.
>
> The fix is to delete lines 364-396 in opal/mca/memory/ptmalloc2/
> malloc.c and move the #include <assert.h> to be inside the
> conditional between lines 2459 and 2461:
>
> 2459 #else
>
> #include <alloc.h>
>
> 2461 #define check_chunk(A,P) do_check_chunk(A,P)
>
>
> Larry Baker
> US Geological Survey
> 650-329-5608
> baker_at_[hidden]
>
> On Aug 17, 2010, at 2:18 PM, Jeff Squyres wrote:
>
>> We still have one known possible regression:
>>
>> https://svn.open-mpi.org/trac/ompi/ticket/2530
>>
>> But we posted rc5 anyway (there's a bunch of stuff that has been
>> pending for a while that is now in). Please test!
>>
>> http://www.open-mpi.org/software/ompi/v1.5/
>>
>> --
>> Jeff Squyres
>> jsquyres_at_[hidden]
>> For corporate legal information go to:
>> http://www.cisco.com/web/about/doing_business/legal/cri/
>>
>>
>> _______________________________________________
>> devel mailing list
>> devel_at_[hidden]
>> http://www.open-mpi.org/mailman/listinfo.cgi/devel
>
> _______________________________________________
> devel mailing list
> devel_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/devel