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: "alan.fitch@xxxxxxxxxx" <alan.fitch@xxxxxxxxxx>
  • From: "Czajkowski, Greg" <greg.czajkowski@xxxxxxxxx>
  • Date: Mon, 15 Nov 2010 14:54:47 -0800
  • Cc: "systemc-forum@xxxxxxxxxxxxxxxxx" <systemc-forum@xxxxxxxxxxxxxxxxx>
Send Email to systemc-forum@lists.systemc.org:
Send new message
Reply to this message
Here is what it looks like roughly

SC_MODULE(top) {
sc_buffer<bool>             pclk;               // pclk is written every 
simulation clock
SC_CTOR(top){
            SC_THREAD(main_loop);
     ...
}

sc_main () {
...
Top = new top("top");
sc_start(1); // This one is ok
...
}

// Future sc_starts are invoked here. Question: Could the explicit call to 
Top->main_loop() be the cause? Doesn't the SystemC kernel invoke main_loop 
since we call SC_THREAD(main_loop) in the SC_CTOR??

int checker_step(uint systime,uint tsctime_high,uint tsctime_low){
    Top->get_time_stamp(systime,tsctime_high,tsctime_low);
    Top->main_loop();
    sc_start(sc_time(sc_dt::uint64(1), true));


From: alan.fitch@xxxxxxxxxx [mailto:alan.fitch@xxxxxxxxxx]
Sent: Friday, November 12, 2010 2:54 AM
To: Czajkowski, Greg
Cc: systemc-forum@xxxxxxxxxxxxxxxxx
Subject: Re: [systemc-forum] Possible causes of segfault during writes to an 
sc_buffer

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<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