I've been trying to use VG for the first time, so I write a simple test
program with an obvious memory leaks:

class Test
{
public:
    Test();
    virtual ~Test();
    void CreateString( int i );
private:
    char* itsString;
};


int main(int argc, char *argv[]) 
{     
     Test* test = new Test();      
     for( int i = 0; i < 20; i++) {         
          test->CreateString(i);     
     }     
     return 1; 
}

Test::Test()
{
    itsString = new char[80];
    sprintf( itsString, "This is the first allocated string\n" );
    printf( "%s", itsString );
}

void Test::CreateString( int i )
{
    itsString = new char[80];      // leak!!!
    sprintf( itsString, "This is allocated string %d\n", i );
    printf( "%s", itsString );
} 

I installed valgrind-3.6.0.SVN-Debian om ubuntu, and VG generates the
following, as expected:

This is the first allocated string
This is allocated string 0
This is allocated string 1
...
==4955== 80 bytes in 1 blocks are definitely lost in loss record 2 of 4
==4955==    at 0x402532E: operator new[](unsigned int)
(vg_replace_malloc.c:299)
==4955==    by 0x8048876: Test::Test() (valgrind_test.cpp:44)
==4955==    by 0x80487A7: main (valgrind_test.cpp:31)
==4955== 
==4955== 88 (8 direct, 80 indirect) bytes in 1 blocks are definitely lost in
loss record 3 of 4
==4955==    at 0x402569A: operator new(unsigned int)
(vg_replace_malloc.c:255)
==4955==    by 0x804879B: main (valgrind_test.cpp:31)
==4955== 
==4955== 1,520 bytes in 19 blocks are definitely lost in loss record 4 of 4
==4955==    at 0x402532E: operator new[](unsigned int)
(vg_replace_malloc.c:299)
==4955==    by 0x8048939: Test::CreateString(int) (valgrind_test.cpp:56)
==4955==    by 0x80487E1: main (valgrind_test.cpp:35)

But, when I profile the same test program with VG cross-compiled on the
Power-PC platform, I get the following errors when VG starts up. To avoid
the well-known strlen issue, I installed non-stripped versions of ld and
libc:
--491-- WARNING: Serious error when reading debug info
--491-- When reading debug info from
/ramfs/tmp/lib/valgrind/vgpreload_core-ppc32-linux.so:
--491-- Can't make sense of .sdata section mapping
--491-- WARNING: Serious error when reading debug info
--491-- When reading debug info from
/ramfs/tmp/lib/valgrind/vgpreload_memcheck-ppc32-linux.so:
--491-- Can't make sense of .sdata section mapping
--491-- WARNING: Serious error when reading debug info
--491-- When reading debug info from /lib/libgcc_s_nof.so.1:
--491-- Can't make sense of .sdata section mapping
==491== Conditional jump or move depends on uninitialised value(s)
==491==    at 0xFCCEBA4: strcmp (in /lib/libc-2.3.2.so)
==491==    by 0xFC6E747: setlocale (in /lib/libc-2.3.2.so)
==491==    by 0xFEFCB2B: std::locale::_Impl::_Impl(unsigned int) (in
/lib/libstdc++.so.6.0.0)
==491==    by 0xFEFD557: ??? (in /lib/libstdc++.so.6.0.0)
==491==    by 0xFEFD5FF: ??? (in /lib/libstdc++.so.6.0.0)
==491==    by 0xFEFD683: std::locale::locale() (in /lib/libstdc++.so.6.0.0)
==491==    by 0xFEFA7F7: std::ios_base::Init::Init() (in
/lib/libstdc++.so.6.0.0)
==491==    by 0x10000DFF: __static_initialization_and_destruction_0(int,
int) (iostream:77)
==491==    by 0x10000E8F: global constructors keyed to main
(valgrind_test.cpp:63)
==491==    by 0x10001223: ??? (in /ramfs/tmp/valgrind_test)
==491==    by 0x10000717: ??? (in /ramfs/tmp/valgrind_test)
==491==    by 0x10000F23: __libc_csu_init (in /ramfs/tmp/valgrind_test)
==491== 
==491== Conditional jump or move depends on uninitialised value(s)
==491==    at 0xFCCEBAC: strcmp (in /lib/libc-2.3.2.so)
==491==    by 0xFC6E747: setlocale (in /lib/libc-2.3.2.so)
==491==    by 0xFEFCB2B: std::locale::_Impl::_Impl(unsigned int) (in
/lib/libstdc++.so.6.0.0)
==491==    by 0xFEFD557: ??? (in /lib/libstdc++.so.6.0.0)
==491==    by 0xFEFD5FF: ??? (in /lib/libstdc++.so.6.0.0)
==491==    by 0xFEFD683: std::locale::locale() (in /lib/libstdc++.so.6.0.0)
==491==    by 0xFEFA7F7: std::ios_base::Init::Init() (in
/lib/libstdc++.so.6.0.0)
==491==    by 0x10000DFF: __static_initialization_and_destruction_0(int,
int) (iostream:77)
==491==    by 0x10000E8F: global constructors keyed to main
(valgrind_test.cpp:63)
==491==    by 0x10001223: ??? (in /ramfs/tmp/valgrind_test)
==491==    by 0x10000717: ??? (in /ramfs/tmp/valgrind_test)
==491==    by 0x10000F23: __libc_csu_init (in /ramfs/tmp/valgrind_test) 

The program also fails to find the memory leaks: 

This is the first allocated string
This is allocated string 0
This is allocated string 1
...
==491== HEAP SUMMARY:
==491==     in use at exit: 0 bytes in 0 blocks
==491==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==491== 
==491== All heap blocks were freed -- no leaks are possible 

I suppose the issues are related.
Can anyone help me?

Many thanks,
Paul





-- 
View this message in context: 
http://old.nabble.com/Errors-when-VG-starts-on-cross-compiled-platform-tp30901558p30901558.html
Sent from the Valgrind - Users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to