Skip Nav
Home » Forums » SystemC Forum

Icon - KMLM List KMLM List

View email archives for the history of this mailing list.

List Home All Archives Dates Threads Authors Subjects
systemc-forum - Re: [systemc-forum] Possible causes of segfault during writes to an sc_b Message Thread: Previous | Next
  • To: "Czajkowski, Greg" <greg.czajkowski@xxxxxxxxx>
  • From: alan.fitch@xxxxxxxxxx
  • Date: Fri, 12 Nov 2010 08:54:25 +0000
  • Cc: "systemc-forum@xxxxxxxxxxxxxxxxx" <systemc-forum@xxxxxxxxxxxxxxxxx>
Send Email to systemc-forum@lists.systemc.org:
Send new message
Reply to this message
It's impossible to say without seeing the code.

However I shall borrow Phillip's crystal ball (thanks Phillip!) and guess 
that you have declared an sc_buffer as an automatic variable, perhaps in a 
constructor of a module, or inside an SC_THREAD after elaboration.

regards
Alan

-- 
Alan Fitch
Senior Consultant

Doulos - Developing Design Know-how
VHDL * Verilog * SystemVerilog * SystemC * PSL * Perl * Tcl/Tk * Project 
Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, 
UK
Tel:  + 44 (0)1425 471223                       Email: 
alan.fitch@xxxxxxxxxx 
Fax:  +44 (0)1425 471573                        http://www.doulos.com

--------------------------------------------------------------------------------
Doulos Ltd is registered in England and Wales with company no. 3723454
Its registered office is 4 Brackley Close, Bournemouth International 
Airport,
 Christchurch, BH23 6SE, UK. 

This message (and associated files) may contain information that is 
confidential, 
proprietary, privileged, or subject to copyright. It is intended solely 
for the use
of the individual to whom it is addressed and others authorised to receive 
it. If
you have received this email in error, please notify the sender and delete 
all
copies. This message may contain personal views which are not the views of
Doulos, unless specifically stated.




From:
"Czajkowski, Greg" <greg.czajkowski@xxxxxxxxx>
To:
"systemc-forum@xxxxxxxxxxxxxxxxx" <systemc-forum@xxxxxxxxxxxxxxxxx>
Date:
12/11/2010 00:12
Subject:
[systemc-forum] Possible causes of segfault during writes to an sc_buffer
Sent by:
<systemc-forum@xxxxxxxxxxxxxxxxx>



Hi, I am looking for causes of a seg fault happening when writing an 
sc_buffer the second sc_start(1) ? (SC_SIGNAL_WRITE_CHECK=DISABLE does not 
cause a segfault)
 
The segfault happens because sc_signal_invalid_writer is dereferencing a 
pointer whose memory has been deleted.
 
Here is how it looks like in Valgrind
 
==8081==    at 0xB8EC7B2: sc_core::sc_object::name() const 
(sc_object.h:80)
==8081==    by 0xB91B051: 
sc_core::sc_signal_invalid_writer(sc_core::sc_object*, 
sc_core::sc_object*, sc_core::sc_object*) (sc_signal.cpp:122)
123         const char* writer1_kind = first_writer->kind();  // 
first_writer has already been deleted
==8081==    by 0xC6DA918: sc_core::sc_buffer<bool>::write(bool const&) 
(sc_buffer.h:159)
154     {
155         sc_object* writer = 
sc_get_curr_simcontext()->get_current_writer();
156         if( sc_signal<T>::m_writer == 0 ) {
157             sc_signal<T>::m_writer = writer;
158         } else if( sc_signal<T>::m_writer != writer ) {
159             sc_signal_invalid_writer( this, sc_signal<T>::m_writer, 
writer );   //This sc_signal<T>::m_writer is bogus and has been already 
deleted.
160         }
==8081==    by 0xC6C606F: sc_core::sc_buffer<bool>::operator=(bool const&) 
(sc_buffer.h:124)
==8081==    by 0xC6C6099: top::main_loop() (top.h:327)
            bool localClk = true;
pclk = localClk; //SEG FAULT HERE
==8081==    by 0xC6C4825: checker_step (main_cte.cpp:126)
126         Top->main_loop();
127         sc_start(1);
==8081==  Address 0x3589c880 is 16 bytes inside a block of size 304 free'd
==8081==    at 0x4B1F76E: operator delete(void*) (vg_replace_malloc.c:346)
==8081==    by 0xB908B9D: sc_core::sc_thread_process::~sc_thread_process() 
(sc_thread_process.cpp:252)
==8081==    by 0xB8F9DC4: sc_core::sc_process_b::reference_decrement() 
(sc_process.h:466)
==8081==    by 0xB8FF45F: sc_core::sc_process_b::kill_process() 
(sc_process.cpp:211)
==8081==    by 0xB90946D: sc_core::sc_thread_process::kill_process() 
(sc_thread_process.cpp:127)
==8081==    by 0xB909655: sc_core::sc_thread_cor_fn(void*) 
(sc_thread_process.cpp:103)
==8081==    by 0xB8EB770: sc_cor_qt_wrapper (sc_cor_qt.cpp:171)
==8081==    by 0xFFFFFFFFFFFFFFFE: ???
==8081== 
==8081== Invalid read of size 8
==8081==    at 0xB91B05D: 
sc_core::sc_signal_invalid_writer(sc_core::sc_object*, 
sc_core::sc_object*, sc_core::sc_object*) (sc_signal.cpp:123)
==8081==    by 0xC6DA918: sc_core::sc_buffer<bool>::write(bool const&) 
(sc_buffer.h:159)
==8081==    by 0xC6C606F: sc_core::sc_buffer<bool>::operator=(bool const&) 
(sc_buffer.h:124)
==8081==    by 0xC6C6099: top::main_loop() (top.h:327)
==8081==    by 0xC6C4825: checker_step (main_cte.cpp:126)
...
==8081==  Address 0x3589c870 is 0 bytes inside a block of size 304 free'd
==8081==    at 0x4B1F76E: operator delete(void*) (vg_replace_malloc.c:346)
==8081==    by 0xB908B9D: sc_core::sc_thread_process::~sc_thread_process() 
(sc_thread_process.cpp:252)
==8081==    by 0xB8F9DC4: sc_core::sc_process_b::reference_decrement() 
(sc_process.h:466)
==8081==    by 0xB8FF45F: sc_core::sc_process_b::kill_process() 
(sc_process.cpp:211)
==8081==    by 0xB90946D: sc_core::sc_thread_process::kill_process() 
(sc_thread_process.cpp:127)
==8081==    by 0xB909655: sc_core::sc_thread_cor_fn(void*) 
(sc_thread_process.cpp:103)
==8081==    by 0xB8EB770: sc_cor_qt_wrapper (sc_cor_qt.cpp:171)
==8081==    by 0xFFFFFFFFFFFFFFFE: ???
 



By Date: Previous | Next Current Thread By Thread: Previous | Next