Bug 336139 - Upon memory check, valgrind hangs and spins on a single core, also fails to detect memory leaks.
Summary: Upon memory check, valgrind hangs and spins on a single core, also fails to d...
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR crash
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-12 18:37 UTC by William Dignazio
Modified: 2014-09-08 10:24 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description William Dignazio 2014-06-12 18:37:16 UTC
Our hardware is MIPS64 Octeon II machines for which we have built software using both the 2.2 and 3.1 Octeon SDK. When the valgrind memcheck tools starts, it hangs up on program execution, spinning somewhere on a single core.

Different compilation options may cause different behaviour, ie. Bus Error. However most commonly valgrind will hang and be unable to detect the memory leaks within an application.

Ex:

$ VALGRIND_LIB=SystemMIPS64_SDK3.1/lib/valgrind ~/SystemMIPS64_SDK3.1/bin/valgrind --leak-check=full ./valgrind-test 
==31151== Memcheck, a memory error detector
==31151== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==31151== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==31151== Command: ./valgrind-test
==31151== 
==31151== Conditional jump or move depends on uninitialised value(s)
==31151==    at 0x1000AA68: malloc (malloc.c:2855)
==31151==    by 0x1003B160: _dl_init_paths (dl-load.c:731)
==31151==    by 0x100119D4: _dl_non_dynamic_init (dl-support.c:271)
==31151==    by 0x10012404: __libc_init_first (init-first.c:82)
==31151==    by 0x10004C8C: (below main) (libc-start.c:164)
==31151== 

..... hangs here indefinitely .....

^C==31151== 
==31151== HEAP SUMMARY:
==31151==     in use at exit: 0 bytes in 0 blocks
==31151==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==31151== 
==31151== All heap blocks were freed -- no leaks are possible
==31151== 
==31151== For counts of detected and suppressed errors, rerun with: -v
==31151== Use --track-origins=yes to see where uninitialised values come from
==31151== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

This output was generated using Valgrind version 3.10.SVN, and has identical output on versions >= 3.8. The code that generated this is a simple while loop that leaks 100 bytes of memory every second. It is provided below.



Reproducible: Always

Steps to Reproduce:
1. Compile Valgrind with the Octeon SDK 3.1 or 2.2 toolchain for MIPS64 (OCTEON_CN63XX)
2. Generate leaky binary with toolchain, the following options in the given example above was: 
"mips64-octeon-linux-gnu-gcc -std=c99 -O0 -ggdb -Wall -march=octeon2 -mabi=64 -msoft-float -static -o valgrind-test valgrind-test.c"
3. Run valgrind on mips platform against generated binary.
Actual Results:  
Hangs on memcheck, fails to detect any memory leaks within application.

Expected Results:  
In example source, a 1000 bytes of leaked memory detected.

I was unable to specify the correct build above, the correct version is 3.10.SVN, I built valgrind itself with the Octeon SDK 3.1 toolchain using the following configuration options:

./configure --enable-only64bit --with-pagesize=4 --prefix=/home/will/SystemMIPS64_SDK3.1 --host=mips64-octeon-linux-gnu

Source for given example of valgrind output:

/*
 * valgrind-test.c
 * This source is in the public domain.
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>

int
main(int argc, char *argv[])
{
        void* leak;

        for(int i=0; i < 10; i++) {
                leak = malloc(100);
                printf("Leak Addr: %p\n", leak);
                sleep(1);
        }

        return 0;
}
Comment 1 Petar Jovanovic 2014-09-04 01:32:49 UTC
(In reply to William Dignazio from comment #0)
> Our hardware is MIPS64 Octeon II machines for which we have built software
> using both the 2.2 and 3.1 Octeon SDK. When the valgrind memcheck tools
> starts, it hangs up on program execution, spinning somewhere on a single
> core.
>
I believe the hang issue should be fixed with VEX r2942.
Please confirm so.

Note that support for Cavium boards is complete if you are using
MIPS64 vanilla rootfs. If you are using rootfs built with Cavium
specific options that will generate some Cavium specific instructions,
then the support is *not* complete and it is being enhanced slowly. This
was the case with this issue as well.