Jump to content

Google profiler / address sanitizer with systemC to detect memory leaks (without --enabled-pthread)


Recommended Posts

Hello,

I have simple hello world program with two threads (one with while(1) and one without) with deliberate memory leaks. Aim is to find out leaks with either google profiler / address sanitizer tool (If this works then plan is to move main application which is much bigger).

When I try to run with either, code fails after sc_stop(). Another interesting thing is if I build systemc library with --enable-pthreads I don't face this issue. what goes wrong when systemC library is not built with --enable-pthreads ?

Error from google profiler:

"Info: /OSCI/SystemC: Simulation stopped by user.

Thread finding failed with -1 errno=14
Thread finding callback was interrupted or crashed; can't fix this"

Error from address sanitizer:

"Info: /OSCI/SystemC: Simulation stopped by user.
==27585==LeakSanitizer has encountered a fatal error."

Does anyone have tried these tools before ? Any idea about this ?

Help is appreciated. Thank you.

Link to post
Share on other sites

Probably because LeakSanitizer was designed with a proper understanding of pthreads; whereas, the non-pthreads implementation uses Q(uick)Threads (or some variant), which implements some assembly language to play with the processor stack to perform context switching. This confuses most if not all memory analysis programs. Pthreads is more universal but slightly slower than QThreads.

Link to post
Share on other sites

David is correct, another program having issues with Quickthreads is valgrind. With Quickthreads SystemC threads actually all live in a single pthread. When a SystemC thread yields to another one the stack is changed from one piece of storage to another in a discontinuous manner. The stack for that single pthread that SystemC is living ends up being discontinuous. With pthreads enabled each SystemC thread is in its own pthread and those stacks are continuous.

Link to post
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.

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