Rinki Posted October 9, 2023 Report Posted October 9, 2023 here i am facing memory deallocation issue while using sc_signal<vctr*> B_in; where vctr is a structure consist vector as a field. Any help? #0 __memcmp_avx2_movbe () at ../sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S:71 #1 0x00007ffff7f2a2a8 in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, sc_core::sc_object_manager::table_entry>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, sc_core::sc_object_manager::table_entry> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, sc_core::sc_object_manager::table_entry> > >::find(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /opt/systemc/lib/libsystemc.so.2.3 #2 0x00007ffff7f29195 in sc_core::sc_object_manager::remove_object(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /opt/systemc/lib/libsystemc.so.2.3 #3 0x00007ffff7f283ed in sc_core::sc_object::detach() () from /opt/systemc/lib/libsystemc.so.2.3 #4 0x00007ffff7f2870d in sc_core::sc_object::~sc_object() () from /opt/systemc/lib/libsystemc.so.2.3 #5 0x000055555557bbde in sc_core::sc_signal_t<vctr*, (sc_core::sc_writer_policy)0>::~sc_signal_t() () #6 0x0000555555577fdc in sc_core::sc_signal<vctr*, (sc_core::sc_writer_policy)0>::~sc_signal() () #7 0x00005555555854c1 in EthernetTransmissionSystem::~EthernetTransmissionSystem() () #8 0x00005555555702b2 in sc_main () #9 0x00007ffff7f20ec6 in sc_elab_and_sim () from /opt/systemc/lib/libsystemc.so.2.3 #10 0x00007ffff79ee083 in __libc_start_main (main=0x7ffff7e6ff90 <main>, argc=1, argv=0x7fffffffe2f8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe2e8) at ../csu/libc-start.c:308 #11 0x000055555556f21e in _start () here is the description i got on back tracing it but did not understand much as i am beginner. Quote
AmeyaVS Posted October 9, 2023 Report Posted October 9, 2023 Hello @Rinki, Welcome to the Accellera Forum. Would it be possible for you share a minimal example of what you are trying out here to comment further? I also have further queries, about the sc_signal<vctr*>, how is the signal assigned? Who owns the data pointed by the vctr*? How is it allocated? Is it going out of scope? Regards, Ameya Vikram Singh Quote
David Black Posted October 9, 2023 Report Posted October 9, 2023 For starters, an sc_signal on a pointer won't work very well since signals depend on comparing the values. Comparing pointers is likely to provide the right answer. You really need to wrap your data in a class and provide the required: Default constructor operator== operator= ostream operator<< Please consider putting a small example of your source code on EDAplayground.com so that we can see and think about your issues more deeply. Quote
Rinki Posted October 10, 2023 Author Report Posted October 10, 2023 13 hours ago, David Black said: For starters, an sc_signal on a pointer won't work very well since signals depend on comparing the values. Comparing pointers is likely to provide the right answer. You really need to wrap your data in a class and provide the required: Default constructor operator== operator= ostream operator<< Please consider putting a small example of your source code on EDAplayground.com so that we can see and think about your issues more deeply. here, sc_signal is used to connect input and output ports of two different modules and to transmit a vector through this. as can't use vector as data type directly so created a structure consist vector and used as a pointer here. SC_MODULE(ETSystem) { sc_signal<vctr*> B_in; // ... SC_CTOR(ETSystem) :reg("reg") , buffer("Buffer") , emac("EMAC") , ephy("EPHY") ,memory("memory"){ // Connect modules initiator = new Initiator("initiator"); initiator->socket.bind(memory.socket); initiator->tx_irq.bind(memory.tx_irq); memory.tx_irpt(flag); reg.tx_enable(flag); memory.output(B_in); buffer.input(B_in); // ... } } Quote
Rinki Posted October 10, 2023 Author Report Posted October 10, 2023 14 hours ago, AmeyaVS said: Hello @Rinki, Welcome to the Accellera Forum. Would it be possible for you share a minimal example of what you are trying out here to comment further? I also have further queries, about the sc_signal<vctr*>, how is the signal assigned? Who owns the data pointed by the vctr*? How is it allocated? Is it going out of scope? Regards, Ameya Vikram Singh signal is used to connect two input and output ports of two different modules and vctr is a structure consist vector as a field as i can't use vector directly as a data type here. in my code i am getting the output what i want and then getting the above mentioned segmentation fault. any idea? Quote
David Black Posted October 16, 2023 Report Posted October 16, 2023 To track down segment faults I recommend using gdb as follows: % # Assume compiled executable is called run.x % gdb run.x gdb> break sc_main gdb> run ... make sure you get here gdb> continue ... crash happens gdb> backtrace ... displays stack trace where crash occured. ... examine each frame looking for code you recognize as yours ... it will tell you the exact FILE_NAME and FILE_NAME where it went South gdb> break FILE_NAME:FILE_NAME gdb> run ... it will stop at the problem area ... you can examine the variables Purchase and read the GDB manual. You will forever benefit from this. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.