Jump to content
manuelselva

Error with a large number of SC_THREAD

Recommended Posts

Hi all,

 

In the context of a SystemC simulation with many SC_THREAD processes (> 32000), I am facing the following error on an Intel X86 platform running Ubuntu 15.04:

 

sc_cor_qt.cpp:114: virtual void sc_core::sc_cor_qt::stack_protect(bool) Assertion `ret == 0' failed

 

I looked into the implementation of the kernel, and here is my current understanding.

 

The default implementation of the SystemC kernel uses user-level threads (also called coroutines) to implement the SystemC processes. The static processes (SC_THREAD and SC_CTHREAD) are initialized in the sc_simcontext.cpp line 759 thread_p->prepare_for_simulation() This function will create the user-level thread object and then enable stack protection.

 

The stack of the user-level thread is allocated in the heap of the SystemC simulation process by the following line

 

cor->m_stack = new char[cor->m_stack_size]

 

The issue I am facing happens in the stack protection function after the creation, that uses an mprotect system call to make the page just after the stack of the user-level thread (again, being in the heap of the Linux process) non accessible at all (PROT_NONE). The error (ENOMEM) I have from mprotect says that this page we want to protect has never been mapped into the process or that the kernel was not able allocate some internal structures while running the mprotect call. Unfortunately I am not able to know which of these two errors happens and how to fix it. Moreover, I can't see where this extra page is allocated in the heap of the Linux process before the mprotect call is made.

 

Does anyone know what is going and/or what can I do know to further debug this issue ?

 

Thank you very much for any help you cna provide on this issue ?

 

----

Manu

 

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

×