Jump to content

Access violation in "string", line 503


Recommended Posts


Recently, I've been having problems with my cout stream when using SystemC. Usually, I just use another stream instead or write to the console using printf as a hotfix, but now SystemC started causing this problem itself, leaving me kind of helpless...

I am using MS Visual Studio 2010. The following project compiles fine using SystemC 2.3.0, but as sc_clock is deprecated, it tries to print some warning about that in the console:

#include <iostream>
#include <systemc.h>
using namespace std;

int sc_main (int argc, char* argv[])
sc_clock clk("Clock",1);

return 0;

When running the resulting project, I'm getting an access violation with the following stack trace (sorry for the messages being German, I hope you can get the gist out of this):

> TestProjectCpp.exe!std::operator<<<char,std::char_traits<char>,std::allocator<char> >(std::basic_ostream<char,std::char_traits<char> > & _Ostr, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Str)  Zeile 503 + 0xf Bytes C++
 TestProjectCpp.exe!sc_core::sc_report_handler::default_handler(const sc_core::sc_report & rep, const unsigned int & actions)  Zeile 119 + 0x5d Bytes C++
 TestProjectCpp.exe!sc_core::sc_report_handler::report(sc_core::sc_severity severity_, const char * msg_type_, const char * msg_, const char * file_, int line_)  Zeile 309 + 0x10 Bytes C++
 TestProjectCpp.exe!sc_core::sc_clock::sc_clock(const char * name_, double period_, double duty_cycle_, double start_time_, bool posedge_first_)  Zeile 187 + 0x1f Bytes C++
 TestProjectCpp.exe!sc_main(int argc, char * * argv)  Zeile 9 C++
 TestProjectCpp.exe!sc_elab_and_sim(int argc, char * * argv)  Zeile 81 + 0x20 Bytes C++
 TestProjectCpp.exe!main(int argc, char * * argv)  Zeile 34 + 0xd Bytes C++
 TestProjectCpp.exe!__tmainCRTStartup()  Zeile 555 + 0x19 Bytes C
 TestProjectCpp.exe!mainCRTStartup()  Zeile 371 C
 [unten angegebene Rahmen sind möglicherweise nicht korrekt und/oder fehlen, keine Symbole geladen für kernel32.dll]

Basically, it's always reporting the line after instanciating sc_clock. The stack trace then points at sc_clock.cpp at

"\n	sc_clock(const char*, double, double, double, bool)\n"
"	is deprecated use a form that includes sc_time or\n"
"	sc_time_unit");

then to sc_report_handler.cpp at line 309

handler(rep, actions);

and at line 119

if ( actions & SC_DISPLAY )
::std::cout << ::std::endl << sc_report_compose_message(rep) <<

The last line being reported is in "string", line 503, which just reads

if (!_Ok)

The debugger states that _Ok is set to true.

I'm really lost here. Any help on how to fix this would be greatly appreciated.

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...