[mpich-discuss] Mpich failing electric-fence check

Jed Brown jed at jedbrown.org
Fri Mar 7 09:25:54 CST 2014


Matthieu Dorier <matthieu.dorier at irisa.fr> writes:
> ElectricFence Aborting: Allocating 0 bytes, probably a bug. 

I would argue that ElectricFence is wrong here.  The standard guarantees
that malloc(0) succeeds and it is useful to simplify code and to test
for matching free in cases where a positive size is rare.

C99 §7.20.3: If the size of the space requested is zero, the behavior is implementation-
defined: either a null pointer is returned, or the behavior is as if the size were some
nonzero value, except that the returned pointer shall not be used to access an object.

Either way, the returned pointer can be passed to free.  Are you aware
of current malloc implementations which violate the above?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mpich.org/pipermail/discuss/attachments/20140307/7d2f0637/attachment.sig>


More information about the discuss mailing list