Le 20/12/2010 15:20, Bernd Kallies a écrit :
> 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
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.
--- src/cpuset.c (révision 2956)
+++ src/cpuset.c (copie de travail)
@@ -535,7 +535,7 @@
- return set->ulongs; /* there's always at least one ulong allocated */
+ return HWLOC_SUBBITMAP_READULONG(set, 0);
unsigned long hwloc_bitmap_to_ith_ulong(const struct hwloc_bitmap_s *set, unsigned i)