Re: Use of valgrind with microthreading

Mark Wielaard <[email protected]>
Newsgroups gmane.comp.debugging.valgrind
Message-ID <[email protected]>
Hi Shachar,

On Fri, Aug 14, 2020 at 06:35:14PM +0300, Shachar Shemesh wrote:
> I am writing my own C++ microthreading library. At the very first switch, I
> get the following message from Valgrind:
> 
> ==15122== Warning: client switching stacks?  SP change: 0x1ffeffe788 -->
> 0x75d0f80
> ==15122==          to suppress, use: --max-stackframe=137298630664 or
> greater
> 
> 
> I understand that valgrind needs to know where the stack starts and ends. I
> am wondering whether is any way I can tell it that information. Since I'm
> writing the library, what I was thinking was compiling the library with a
> special flag saying "you're running with valgrind", and then have my library
> call a valgrind function that says "This is the new stack range, this is the
> old one".
>  
> Is there such a thing? If so, how do I interface with it?

Yes, there is such a thing. The valgrind client request mechanism:
https://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq

It does have various VALGRIND_STACK_* macros to signal use of user
threads/stacks. But note that the documentations says:
Warning: Unfortunately, this client request is unreliable and best avoided.
Unfortunately I don't know why that is, or what alternative mechanisms there are.

Cheers,

Mark
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.