Re: [Valgrind-users] Use of valgrind with microthreading

2020-08-15 Thread Philippe Waroquiers
On Fri, 2020-08-14 at 19:16 +0200, Mark Wielaard wrote:
> 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.

I also do not know what the 'unreliable' doc warning points at.
Searching in bugzilla, there are a few bugs that are related to such STACK 
requests:
Bug 202463 - VALGRIND_STACK_{REGISTER,DEREGISTER,CHANGE} are unreliable 
Bug 133154 - crash when using client requests to register/deregister stack

However, some years ago, I did various improvements to the stack handling code
in order to better support running valgrind under valgrind: the inner valgrind 
is
using such client requests to inform the outer valgrind about the inner stacks.

So, IMO, these requests should (could?) work reasonably well.

Philippe

 




___
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users


Re: [Valgrind-users] Use of valgrind with microthreading

2020-08-14 Thread Mark Wielaard
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


___
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users


[Valgrind-users] Use of valgrind with microthreading

2020-08-14 Thread Shachar Shemesh

Hi all,


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?


Thank you,

Shachar


___
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users