kocha

SystemC 2.3:valgrind error

6 posts in this topic

Bonjours,

I was trying to execute valgrind this example code.

But, error message was displayed.

Not SystemC 2.2 is error message.

What is a cause?

・Example code

#include <systemc>
using namespace sc_core;
SC_MODULE(hoge) {
 SC_CTOR(hoge)
 {
SC_THREAD(T);
f = 0;
 }

 int f;
 void T(){
 }
};
int sc_main(int argc, char* argv[])
{
 hoge *uhoge;
 uhoge = new hoge("uhoge");
 sc_start();
 delete uhoge;
 return 0;
}

・Error Message(valgrind option)

$> valgrind --leak-check=full ./main

==2289== Memcheck, a memory error detector
==2289== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==2289== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==2289== Command: ./main
==2289==
		 SystemC 2.3.0-ASI --- Jul 13 2012 06:33:43
	Copyright (c) 1996-2012 by all Contributors,
	ALL RIGHTS RESERVED
==2289== Warning: client switching stacks?  SP change: 0xbea9fcdc --> 0x47befe0
==2289==		  to suppress, use: --max-stackframe=1171387140 or greater
==2289== Warning: client switching stacks?  SP change: 0x47bef64 --> 0xbea9fcdc
==2289==		  to suppress, use: --max-stackframe=1171387016 or greater
==2289==
==2289== HEAP SUMMARY:
==2289==	 in use at exit: 108,173 bytes in 328 blocks
==2289==   total heap usage: 364 allocs, 36 frees, 3,395,961 bytes allocated
==2289==
==2289== 18 bytes in 1 blocks are possibly lost in loss record 14 of 61
==2289==	at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x42187D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218AB3: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218C41: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218CF8: std::string::assign(char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4092A99: sc_core::sc_object_manager::create_name(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x4091558: sc_core::sc_object::sc_object_init(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x4091D17: sc_core::sc_object::sc_object(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x408DEE0: sc_core::sc_module::sc_module() (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x8049735: hoge::hoge(sc_core::sc_module_name) (sc_main.cpp:6)
==2289==	by 0x80494CE: sc_main (sc_main.cpp:19)
==2289==	by 0x408C105: sc_elab_and_sim (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==
==2289== 23 bytes in 1 blocks are possibly lost in loss record 18 of 61
==2289==	at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x42187D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x146B003: ???
==2289==
==2289== 30 bytes in 1 blocks are possibly lost in loss record 22 of 61
==2289==	at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x42187D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218AB3: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218C41: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218CF8: std::string::assign(char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4092A99: sc_core::sc_object_manager::create_name(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x4091558: sc_core::sc_object::sc_object_init(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x4091D17: sc_core::sc_object::sc_object(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x409531D: sc_core::sc_process_b::sc_process_b(char const*, bool, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x408D516: sc_core::sc_method_process::sc_method_process(char const*, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x409CC13: sc_core::sc_simcontext::prepare_to_simulate() (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x409D3A1: sc_core::sc_simcontext::initialize(bool) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==
==2289== 30 bytes in 1 blocks are possibly lost in loss record 23 of 61
==2289==	at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x42187D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218AB3: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218C41: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218CF8: std::string::assign(char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4092A99: sc_core::sc_object_manager::create_name(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x4091558: sc_core::sc_object::sc_object_init(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x4091D17: sc_core::sc_object::sc_object(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x409531D: sc_core::sc_process_b::sc_process_b(char const*, bool, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x40A29C6: sc_core::sc_thread_process::sc_thread_process(char const*, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x409CBA4: sc_core::sc_simcontext::prepare_to_simulate() (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x409D3A1: sc_core::sc_simcontext::initialize(bool) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==
==2289== 35 bytes in 1 blocks are possibly lost in loss record 24 of 61
==2289==	at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x42187D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218AB3: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218C41: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218CF8: std::string::assign(char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4092A99: sc_core::sc_object_manager::create_name(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x4091558: sc_core::sc_object::sc_object_init(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x4091D17: sc_core::sc_object::sc_object(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x408DEE0: sc_core::sc_module::sc_module() (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x409A757: sc_core::sc_simcontext::elaborate() (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==
==2289== 45 bytes in 1 blocks are possibly lost in loss record 29 of 61
==2289==	at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x42187D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218AB3: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218C41: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218CF8: std::string::assign(char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4092A99: sc_core::sc_object_manager::create_name(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x4088EAA: sc_core::sc_event::register_event(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x4089070: sc_core::sc_event::sc_event(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x40954DC: sc_core::sc_process_b::sc_process_b(char const*, bool, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x408D516: sc_core::sc_method_process::sc_method_process(char const*, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x409CC13: sc_core::sc_simcontext::prepare_to_simulate() (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x409D3A1: sc_core::sc_simcontext::initialize(bool) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==
==2289== 45 bytes in 1 blocks are possibly lost in loss record 30 of 61
==2289==	at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x42187D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218AB3: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218C41: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4218CF8: std::string::assign(char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x4092A99: sc_core::sc_object_manager::create_name(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x4088EAA: sc_core::sc_event::register_event(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x4089070: sc_core::sc_event::sc_event(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x40954DC: sc_core::sc_process_b::sc_process_b(char const*, bool, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x40A29C6: sc_core::sc_thread_process::sc_thread_process(char const*, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x409CBA4: sc_core::sc_simcontext::prepare_to_simulate() (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x409D3A1: sc_core::sc_simcontext::initialize(bool) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==
==2289== 57 bytes in 1 blocks are possibly lost in loss record 34 of 61
==2289==	at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x42187D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2289==	by 0x3: ???
==2289==
==2289== 2,048 bytes in 256 blocks are possibly lost in loss record 48 of 61
==2289==	at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x411BD08: sc_dt::sc_unsigned::sc_unsigned(int) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x412B47B: sc_core::sc_vpool<sc_dt::sc_unsigned>::sc_vpool(int, sc_dt::sc_unsigned*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x40879D9: _GLOBAL__sub_I_sc_unsigned.cpp (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x400EEAA: call_init (dl-init.c:85)
==2289==	by 0x400EF93: _dl_init (dl-init.c:134)
==2289==	by 0x400120E: ??? (in /lib/i386-linux-gnu/ld-2.15.so)
==2289==
==2289== 4,100 bytes in 1 blocks are possibly lost in loss record 49 of 61
==2289==	at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x4087B33: _GLOBAL__sub_I_sc_concatref.cpp (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x400EEAA: call_init (dl-init.c:85)
==2289==	by 0x400EF93: _dl_init (dl-init.c:134)
==2289==	by 0x400120E: ??? (in /lib/i386-linux-gnu/ld-2.15.so)
==2289==
==2289== 5,124 bytes in 1 blocks are possibly lost in loss record 50 of 61
==2289==	at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x412B415: sc_core::sc_vpool<sc_dt::sc_unsigned>::sc_vpool(int, sc_dt::sc_unsigned*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x40879D9: _GLOBAL__sub_I_sc_unsigned.cpp (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x400EEAA: call_init (dl-init.c:85)
==2289==	by 0x400EF93: _dl_init (dl-init.c:134)
==2289==	by 0x400120E: ??? (in /lib/i386-linux-gnu/ld-2.15.so)
==2289==
==2289== 6,148 bytes in 1 blocks are possibly lost in loss record 51 of 61
==2289==	at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x40874C3: _GLOBAL__sub_I_sc_int_base.cpp (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x400EEAA: call_init (dl-init.c:85)
==2289==	by 0x400EF93: _dl_init (dl-init.c:134)
==2289==	by 0x400120E: ??? (in /lib/i386-linux-gnu/ld-2.15.so)
==2289==
==2289== 6,148 bytes in 1 blocks are possibly lost in loss record 52 of 61
==2289==	at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x4087773: _GLOBAL__sub_I_sc_signed.cpp (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x400EEAA: call_init (dl-init.c:85)
==2289==	by 0x400EF93: _dl_init (dl-init.c:134)
==2289==	by 0x400120E: ??? (in /lib/i386-linux-gnu/ld-2.15.so)
==2289==
==2289== 6,148 bytes in 1 blocks are possibly lost in loss record 53 of 61
==2289==	at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x40878A3: _GLOBAL__sub_I_sc_uint_base.cpp (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x400EEAA: call_init (dl-init.c:85)
==2289==	by 0x400EF93: _dl_init (dl-init.c:134)
==2289==	by 0x400120E: ??? (in /lib/i386-linux-gnu/ld-2.15.so)
==2289==
==2289== 6,148 bytes in 1 blocks are possibly lost in loss record 54 of 61
==2289==	at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x4087A07: _GLOBAL__sub_I_sc_unsigned.cpp (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x400EEAA: call_init (dl-init.c:85)
==2289==	by 0x400EF93: _dl_init (dl-init.c:134)
==2289==	by 0x400120E: ??? (in /lib/i386-linux-gnu/ld-2.15.so)
==2289==
==2289== 8,196 bytes in 1 blocks are possibly lost in loss record 55 of 61
==2289==	at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x408752E: _GLOBAL__sub_I_sc_int_base.cpp (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x400EEAA: call_init (dl-init.c:85)
==2289==	by 0x400EF93: _dl_init (dl-init.c:134)
==2289==	by 0x400120E: ??? (in /lib/i386-linux-gnu/ld-2.15.so)
==2289==
==2289== 8,196 bytes in 1 blocks are possibly lost in loss record 56 of 61
==2289==	at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x40877DE: _GLOBAL__sub_I_sc_signed.cpp (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x400EEAA: call_init (dl-init.c:85)
==2289==	by 0x400EF93: _dl_init (dl-init.c:134)
==2289==	by 0x400120E: ??? (in /lib/i386-linux-gnu/ld-2.15.so)
==2289==
==2289== 8,196 bytes in 1 blocks are possibly lost in loss record 57 of 61
==2289==	at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x408790E: _GLOBAL__sub_I_sc_uint_base.cpp (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x400EEAA: call_init (dl-init.c:85)
==2289==	by 0x400EF93: _dl_init (dl-init.c:134)
==2289==	by 0x400120E: ??? (in /lib/i386-linux-gnu/ld-2.15.so)
==2289==
==2289== 8,196 bytes in 1 blocks are possibly lost in loss record 58 of 61
==2289==	at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x4087A76: _GLOBAL__sub_I_sc_unsigned.cpp (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x400EEAA: call_init (dl-init.c:85)
==2289==	by 0x400EF93: _dl_init (dl-init.c:134)
==2289==	by 0x400120E: ??? (in /lib/i386-linux-gnu/ld-2.15.so)
==2289==
==2289== 12,292 bytes in 1 blocks are possibly lost in loss record 61 of 61
==2289==	at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2289==	by 0x4087B94: _GLOBAL__sub_I_sc_concatref.cpp (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)
==2289==	by 0x400EEAA: call_init (dl-init.c:85)
==2289==	by 0x400EF93: _dl_init (dl-init.c:134)
==2289==	by 0x400120E: ??? (in /lib/i386-linux-gnu/ld-2.15.so)
==2289==
==2289== LEAK SUMMARY:
==2289==	definitely lost: 0 bytes in 0 blocks
==2289==	indirectly lost: 0 bytes in 0 blocks
==2289==	  possibly lost: 81,223 bytes in 275 blocks
==2289==	still reachable: 26,950 bytes in 53 blocks
==2289==		 suppressed: 0 bytes in 0 blocks
==2289== Reachable blocks (those to which a pointer was found) are not shown.
==2289== To see them, rerun with: --leak-check=full --show-reachable=yes
==2289==
==2289== For counts of detected and suppressed errors, rerun with: -v
==2289== ERROR SUMMARY: 20 errors from 20 contexts (suppressed: 0 from 0)

- Ubuntu12.04 32bit

- GCC 4.4.7

- Valgrind 3.7.0

Thanks.

Share this post


Link to post
Share on other sites

Admittedly, using Valgrind with SystemC has become more involved with 2.3. There are several reasons for this, some of them are new, some apply to SystemC 2.2 already. Let's have a look at your output:

==2289== Warning: client switching stacks?  SP change: 0xbea9fcdc --> 0x47befe0
==2289==		  to suppress, use: --max-stackframe=1171387140 or greater

In order to reliably use SystemC with Valgrind, you should switch to the pthreads-based process implementation. Otherwise, you'll see many false positives when looking at "real" models. To enable this in 2.3, add "--enable-pthreads" to the configure options and recompile the library:

 cd objdir
 ../configure --enable-pthreads (...)
 make clean && make && make install

==2289== WW bytes in X blocks are possibly lost in loss record YY of ZZ
...
==2289==	by 0x4092A99: sc_core::sc_object_manager::create_name(char const*) (in /usr/local/lib/systemc-2.3.0/lib-linux/libsystemc-2.3.0.so)

These are false positives due to the internal name handling of SystemC. There are several global objects which are deliberately not freed. The unique name counters of the top-level objects are among them. Ignore those.

(In principle, these have been present in 2.2 already. There were less instances, since events had no name.)

==2289==  WW bytes in X blocks are possibly lost in loss record YY of ZZ
...
==2289==	by 0x400EF93: _dl_init (dl-init.c:134)

All of these false positives are a result from using the shared library, instead of linking statically against SystemC.

The global objects (and the memory allocated by them) can not be tracked down by Valgrind in this case. Moreover, there are still object instances from the shared library present in the running program and the dynamic library will not be unloaded.

To link statically against the (pthreads-enabled) SystemC library in your environment, add -pthread to your compiler flags and use

-Wl,-Bstatic -lsystemc -Wl,-Bdynamic -pthread

for the SystemC library linker flags.

==2289== LEAK SUMMARY:
==2289==	definitely lost: 0 bytes in 0 blocks
==2289==	indirectly lost: 0 bytes in 0 blocks
==2289==	  possibly lost: 81,223 bytes in 275 blocks
==2289==	still reachable: 26,950 bytes in 53 blocks
==2289==		 suppressed: 0 bytes in 0 blocks

The most important result here is that no definite or indirect losses are reported. These are the real leaks.

Some of reported "possible losses" can further be suppressed by exporting the following environment variable:

export SYSTEMC_MEMPOOL_DONT_USE=1
# (or setenv, in case of csh-compatible shells)

Greetings from Oldenburg,

Philipp

Share this post


Link to post
Share on other sites

hi,

Thank you very much for your answer but valgring error not zero.

I tryed install option add "--enable-pthreads" and linker flags "-Wl,-Bstatic -lsystemc -Wl,-Bdynamic -pthread" .

And environment variable "SYSTEMC_MEMPOOL_DONT_USE=1".

■ Valgrind message

==2566== Memcheck, a memory error detector
==2566== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==2566== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==2566== Command: ./main
==2566==
		 SystemC 2.3.0-ASI --- Feb 16 2013 23:56:43
    Copyright (c) 1996-2012 by all Contributors,
    ALL RIGHTS RESERVED
==2566==
==2566== HEAP SUMMARY:
==2566==	 in use at exit: 25,233 bytes in 58 blocks
==2566==   total heap usage: 90 allocs, 32 frees, 35,253 bytes allocated
==2566==
==2566== 18 bytes in 1 blocks are possibly lost in loss record 13 of 50
==2566==    at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2566==    by 0x40D87D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8AB3: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8C41: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8CF8: std::string::assign(char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x8053E13: sc_core::sc_object_manager::create_name(char const*) (basic_string.h:975)
==2566==    by 0x805257E: sc_core::sc_object::sc_object_init(char const*) (sc_object.cpp:188)
==2566==    by 0x8052AD3: sc_core::sc_object::sc_object(char const*) (sc_object.cpp:267)
==2566==    by 0x8050214: sc_core::sc_module::sc_module() (sc_module.cpp:184)
==2566==    by 0x804D345: hoge::hoge(sc_core::sc_module_name) (sc_main.cpp:6)
==2566==    by 0x804D0DE: sc_main (sc_main.cpp:19)
==2566==    by 0x804D7C7: sc_elab_and_sim (sc_main_main.cpp:81)
==2566==
==2566== 23 bytes in 1 blocks are possibly lost in loss record 17 of 50
==2566==    at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2566==    by 0x40D87D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x146B0BD: ???
==2566==
==2566== 30 bytes in 1 blocks are possibly lost in loss record 26 of 50
==2566==    at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2566==    by 0x40D87D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8AB3: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8C41: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8CF8: std::string::assign(char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x8053E13: sc_core::sc_object_manager::create_name(char const*) (basic_string.h:975)
==2566==    by 0x805257E: sc_core::sc_object::sc_object_init(char const*) (sc_object.cpp:188)
==2566==    by 0x8052AD3: sc_core::sc_object::sc_object(char const*) (sc_object.cpp:267)
==2566==    by 0x8055CBA: sc_core::sc_process_b::sc_process_b(char const*, bool, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (sc_process.cpp:576)
==2566==    by 0x8079200: sc_core::sc_method_process::sc_method_process(char const*, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (sc_method_process.cpp:304)
==2566==    by 0x8060227: sc_core::sc_runnable::init() (sc_runnable_int.h:137)
==2566==    by 0x805DFC2: sc_core::sc_simcontext::prepare_to_simulate() (sc_simcontext.cpp:721)
==2566==
==2566== 30 bytes in 1 blocks are possibly lost in loss record 27 of 50
==2566==    at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2566==    by 0x40D87D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8AB3: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8C41: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8CF8: std::string::assign(char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x8053E13: sc_core::sc_object_manager::create_name(char const*) (basic_string.h:975)
==2566==    by 0x805257E: sc_core::sc_object::sc_object_init(char const*) (sc_object.cpp:188)
==2566==    by 0x8052AD3: sc_core::sc_object::sc_object(char const*) (sc_object.cpp:267)
==2566==    by 0x8055CBA: sc_core::sc_process_b::sc_process_b(char const*, bool, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (sc_process.cpp:576)
==2566==    by 0x8063620: sc_core::sc_thread_process::sc_thread_process(char const*, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (sc_thread_process.cpp:354)
==2566==    by 0x80601B7: sc_core::sc_runnable::init() (sc_runnable_int.h:148)
==2566==    by 0x805DFC2: sc_core::sc_simcontext::prepare_to_simulate() (sc_simcontext.cpp:721)
==2566==
==2566== 35 bytes in 1 blocks are possibly lost in loss record 28 of 50
==2566==    at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2566==    by 0x40D87D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8AB3: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8C41: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8CF8: std::string::assign(char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x8053E13: sc_core::sc_object_manager::create_name(char const*) (basic_string.h:975)
==2566==    by 0x805257E: sc_core::sc_object::sc_object_init(char const*) (sc_object.cpp:188)
==2566==    by 0x8052AD3: sc_core::sc_object::sc_object(char const*) (sc_object.cpp:267)
==2566==    by 0x8050214: sc_core::sc_module::sc_module() (sc_module.cpp:184)
==2566==    by 0x805C9BE: sc_core::sc_simcontext::elaborate() (sc_simcontext.cpp:257)
==2566==    by 0x805E22F: sc_core::sc_simcontext::initialize(bool) (sc_simcontext.cpp:819)
==2566==    by 0x805E309: sc_core::sc_simcontext::simulate(sc_core::sc_time const&) (sc_simcontext.cpp:846)
==2566==
==2566== 45 bytes in 1 blocks are possibly lost in loss record 32 of 50
==2566==    at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2566==    by 0x40D87D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8AB3: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8C41: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8CF8: std::string::assign(char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x8053E13: sc_core::sc_object_manager::create_name(char const*) (basic_string.h:975)
==2566==    by 0x80763F4: sc_core::sc_event::register_event(char const*) (sc_event.cpp:194)
==2566==    by 0x80769A9: sc_core::sc_event::sc_event(char const*) (sc_event.cpp:243)
==2566==    by 0x8055E77: sc_core::sc_process_b::sc_process_b(char const*, bool, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (sc_process.cpp:583)
==2566==    by 0x8079200: sc_core::sc_method_process::sc_method_process(char const*, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (sc_method_process.cpp:304)
==2566==    by 0x8060227: sc_core::sc_runnable::init() (sc_runnable_int.h:137)
==2566==    by 0x805DFC2: sc_core::sc_simcontext::prepare_to_simulate() (sc_simcontext.cpp:721)
==2566==
==2566== 45 bytes in 1 blocks are possibly lost in loss record 33 of 50
==2566==    at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2566==    by 0x40D87D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8AB3: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8C41: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x40D8CF8: std::string::assign(char const*, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x8053E13: sc_core::sc_object_manager::create_name(char const*) (basic_string.h:975)
==2566==    by 0x80763F4: sc_core::sc_event::register_event(char const*) (sc_event.cpp:194)
==2566==    by 0x80769A9: sc_core::sc_event::sc_event(char const*) (sc_event.cpp:243)
==2566==    by 0x8055E77: sc_core::sc_process_b::sc_process_b(char const*, bool, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (sc_process.cpp:583)
==2566==    by 0x8063620: sc_core::sc_thread_process::sc_thread_process(char const*, bool, void (sc_core::sc_process_host::*)(), sc_core::sc_process_host*, sc_core::sc_spawn_options const*) (sc_thread_process.cpp:354)
==2566==    by 0x80601B7: sc_core::sc_runnable::init() (sc_runnable_int.h:148)
==2566==    by 0x805DFC2: sc_core::sc_simcontext::prepare_to_simulate() (sc_simcontext.cpp:721)
==2566==
==2566== 57 bytes in 1 blocks are possibly lost in loss record 36 of 50
==2566==    at 0x402B9B4: operator new(unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2566==    by 0x40D87D3: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16)
==2566==    by 0x2191803: ???
==2566==
==2566== 144 bytes in 1 blocks are possibly lost in loss record 39 of 50
==2566==    at 0x402A5E6: calloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2566==    by 0x4011304: allocate_dtv (dl-tls.c:297)
==2566==    by 0x4011AAB: _dl_allocate_tls (dl-tls.c:461)
==2566==    by 0x417E470: pthread_create@@GLIBC_2.1 (allocatestack.c:571)
==2566==    by 0x80756B6: sc_core::sc_cor_pkg_pthread::create(unsigned int, void (*)(void*), void*) (sc_cor_pthread.cpp:213)
==2566==    by 0x80627F2: sc_core::sc_thread_process::prepare_for_simulation() (sc_thread_process.cpp:284)
==2566==    by 0x805DF9F: sc_core::sc_simcontext::prepare_to_simulate() (sc_simcontext.cpp:716)
==2566==    by 0x805E237: sc_core::sc_simcontext::initialize(bool) (sc_simcontext.cpp:821)
==2566==    by 0x805E309: sc_core::sc_simcontext::simulate(sc_core::sc_time const&) (sc_simcontext.cpp:846)
==2566==    by 0x805F15C: sc_core::sc_start(sc_core::sc_time const&, sc_core::sc_starvation_policy) (sc_simcontext.cpp:1583)
==2566==    by 0x805F2BB: sc_core::sc_start() (sc_simcontext.cpp:1617)
==2566==    by 0x804D105: sc_main (sc_main.cpp:20)
==2566==
==2566== LEAK SUMMARY:
==2566==    definitely lost: 0 bytes in 0 blocks
==2566==    indirectly lost: 0 bytes in 0 blocks
==2566==	  possibly lost: 427 bytes in 9 blocks
==2566==    still reachable: 24,806 bytes in 49 blocks
==2566==		 suppressed: 0 bytes in 0 blocks
==2566== Reachable blocks (those to which a pointer was found) are not shown.
==2566== To see them, rerun with: --leak-check=full --show-reachable=yes
==2566==
==2566== For counts of detected and suppressed errors, rerun with: -v
==2566== ERROR SUMMARY: 9 errors from 9 contexts (suppressed: 0 from 0)

Thanks.

Share this post


Link to post
Share on other sites

As explained in detail in my previous answer, the output you see is as expected.

All of these reports (which are no errors in a strict sense) can be seen as false positives. The additional "possible loss" reported (the one with pthread_create in the call tree) is related to the stack allocation of your process.

/Philipp

Share this post


Link to post
Share on other sites

Hi,
sorry for opening up this old thread- but I am seeing the same error.

SC_THREAD example:

SC_MODULE(threadTest)
{
  void test()
  {
    sc_stop();
  }
  SC_CTOR(threadTest)
  {
    SC_THREAD(test);
  }

};
int main_sc_thread_test2()
{
    threadTest test("Test");
    sc_start();
    return 0;
}

I get the following message when I run the above code with SystemC 2.3 (pthreads) and valgrind:

==131808== 736 bytes in 1 blocks are possibly lost in loss record 60 of 76
==131808==    at 0x4A057BB: calloc (vg_replace_malloc.c:593)
==131808==    by 0x33736119A2: _dl_allocate_tls (in /lib64/ld-2.12.so)
==131808==    by 0x33742072CC: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.12.so)
==131808==    by 0x5B4C37C: sc_core::sc_cor_pkg_pthread::create(unsigned long, void (*)(void*), void*) (sc_cor_pthread.cpp:213)
==131808==    by 0x5B3B575: sc_core::sc_thread_process::prepare_for_simulation() (sc_thread_process.cpp:329)
==131808==    by 0x5B3668C: sc_core::sc_simcontext::prepare_to_simulate() (sc_simcontext.cpp:756)
==131808==    by 0x5B36A86: sc_core::sc_simcontext::initialize(bool) (sc_simcontext.cpp:867)
==131808==    by 0x5B36B49: sc_core::sc_simcontext::simulate(sc_core::sc_time const&) (sc_simcontext.cpp:892)
==131808==    by 0x5B36FC9: sc_core::sc_start(sc_core::sc_time const&, sc_core::sc_starvation_policy) (sc_simcontext.cpp:1695)
==131808==    by 0x5B37155: sc_core::sc_start() (sc_simcontext.cpp:1729)
==131808==    by 0x414256: main_sc_thread_test2() (main.cpp:)

 

Phillip commented:
>> The additional "possible loss" reported (the one with pthread_create in the call tree) is related to the stack allocation of your process.

I don't know how to interpret this comment.
Is there a way to get rid of this error, or is this simply a false-positive which should be suppressed?

 

Best regards,
Jonas

 

Share this post


Link to post
Share on other sites

Hi Jonas,

for now, this is a known leak (as stacks from statically created processes are currently deliberately not deleted) and allocations from 

sc_core::sc_cor_pkg_*::create

should be suppressed. (Dynamically created threads are not affected, so it is not a "real" leak).

Greetings from Duisburg,
  Philipp

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now