Open MPI logo

Hardware Locality Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Hardware Locality Development mailing list

Subject: Re: [hwloc-devel] Bug in v1.1 bitmap API
From: Brice Goglin (Brice.Goglin_at_[hidden])
Date: 2010-12-20 09:34:50

Le 20/12/2010 15:20, Bernd Kallies a écrit :
> Hallo,
> while browsing through the implementation of the bitmap API in hwloc 1.1
> and comparing it with the cpuset API of hwloc 1.0, it turns out that
> hwloc_bitmap_alloc uses malloc and leaves struct member ulongs
> uninitialized, wheres 1.0 used calloc.
> This leads to random bitmap content after creation with
> hwloc_bitmap_alloc, depending on how system's malloc works. In addition,
> these bitmaps cannot be zeroed with hwloc_bitmap_zero right after alloc.
> One may check this with the call sequence
> hwloc_bitmap_alloc
> hwloc_bitmap_to_ulong

The actual problem is that the internal code assumes that there's always
at least one initialized ulong. In the past, we allocated multiple
ulongs by default, initialized only the first one, and initialized the
other ones later only when needed.
In the final 1.1, we don't even initialize the first ulong (IIRC, it
made some empty/full bitmaps nicer in printf). I need to fix the code
that wasn't updated accordingly. The attached patch should work.


Index: src/cpuset.c
--- src/cpuset.c (révision 2956)
+++ src/cpuset.c (copie de travail)
@@ -535,7 +535,7 @@
- return set->ulongs[0]; /* there's always at least one ulong allocated */
 unsigned long hwloc_bitmap_to_ith_ulong(const struct hwloc_bitmap_s *set, unsigned i)