The attached patch fixed it for me on F12. Some libnuma helpers were
clearing too many bytes when resetting libnuma mask.

Brice



Le 11/11/2010 14:15, Jirka Hladky a écrit :
> Hi Brice,
>
> this one is tricky. I don't see this crash when compiling by hand 
> (./configure 
> && make && make check). I see the crash only when building with rpmbuild. It 
> happens both with 2694 and 2751.
>
> rpmbuild is applying automatically CFLAGS flags. Finally, I have reduced it to
>
> cd hwloc-1.2a1r2751/
> export CFLAGS='-O2'
> ./configure && make && make check
>
> It works fine with -O1
>
> Please try if you can reproduce the problem with
> =======================================================
> $make clean && export CFLAGS='-g -O2' && ./configure && make && make check
> =======================================================
>
>
> This is gdb output:
> =====================================================
> gdb /tmp/J/hwloc-1.2a1r2751/tests/.libs/lt-linux-libnuma
> (gdb) run
> Starting program: /tmp/J/hwloc-1.2a1r2751/tests/.libs/lt-linux-libnuma 
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff7deb632 in hwloc_get_type_depth (topology=0x0, 
> type=HWLOC_OBJ_NODE) 
> at traversal.c:17
> =====================================================
>
> I have the feeling it's gcc bug. Any feedback?
>
> Thanks
> Jirka
>
>
> On Wednesday, November 10, 2010 07:33:19 pm Brice Goglin wrote:
>   
>> I don't see any change in this test between 2694 and 2751. Do you get a
>> better backtrace if you compile in debug mode (and/or with CFLAGS="-g
>> -O0") or with gdb?
>>
>> Brice
>>
>> Le 10/11/2010 15:56, Jirka Hladky a écrit :
>>     
>>> Hi Brice,
>>>
>>> just a quick check.
>>>
>>> I see following when running make check for hwloc-1.2a1r2694
>>>
>>> ======================================================
>>> PASS: hwloc_insert_misc
>>> *** buffer overflow detected ***:
>>> /home/jhladky/rpmbuild/BUILD/hwloc-1.2a1r2694/tests/.libs/lt-linux-libnum
>>> a terminated
>>> ======= Backtrace: =========
>>> /lib64/libc.so.6(__fortify_fail+0x37)[0x30cfcf7707]
>>> /lib64/libc.so.6[0x30cfcf5720]
>>> /home/jhladky/rpmbuild/BUILD/hwloc-1.2a1r2694/tests/.libs/lt-linux-
>>> libnuma[0x401ae9]
>>> /lib64/libc.so.6(__libc_start_main+0xfd)[0x30cfc1eb1d]
>>> /home/jhladky/rpmbuild/BUILD/hwloc-1.2a1r2694/tests/.libs/lt-linux-
>>> libnuma[0x401059]
>>> ======= Memory map: ========
>>> 00400000-00404000 r-xp 00000000 fd:00 1230911
>>> /home/jhladky/rpmbuild/BUILD/hwloc-1.2a1r2694/tests/.libs/lt-linux-libnum
>>> a 00603000-00604000 rw-p 00003000 fd:00 1230911
>>> /home/jhladky/rpmbuild/BUILD/hwloc-1.2a1r2694/tests/.libs/lt-linux-libnum
>>> a 019a6000-019c7000 rw-p 00000000 00:00 0
>>> [heap]
>>> 30cf800000-30cf81e000 r-xp 00000000 08:02 48991
>>> /lib64/ld-2.11.2.so
>>> ===================================================
>>>
>>> It's running just fine when using hwloc-1.2a1r2751
>>>
>>> Have you fixed this test in hwloc-1.2a1r2751?
>>>
>>> Thanks!
>>> Jirka
>>>       

Index: include/hwloc/linux-libnuma.h
===================================================================
--- include/hwloc/linux-libnuma.h	(révision 2772)
+++ include/hwloc/linux-libnuma.h	(copie de travail)
@@ -47,7 +47,8 @@
   unsigned long outmaxnode = -1;

   /* round-up to the next ulong and clear all bytes */
-  memset(mask, 0, (*maxnode+8*sizeof(*mask)-1)/8);
+  *maxnode = (*maxnode + 8*sizeof(*mask) - 1) & ~(8*sizeof(*mask) - 1);
+  memset(mask, 0, *maxnode/8);

   if (depth != HWLOC_TYPE_DEPTH_UNKNOWN) {
     hwloc_obj_t node = NULL;
@@ -89,7 +90,8 @@
   unsigned long outmaxnode = -1;

   /* round-up to the next ulong and clear all bytes */
-  memset(mask, 0, (*maxnode+8*sizeof(*mask)-1)/8);
+  *maxnode = (*maxnode + 8*sizeof(*mask) - 1) & ~(8*sizeof(*mask) - 1);
+  memset(mask, 0, *maxnode/8);

   if (depth != HWLOC_TYPE_DEPTH_UNKNOWN) {
     hwloc_obj_t node = NULL;

Reply via email to