|
From: Evan J.
|
I am working on a thread library that maps user space threads to kernel threads (as provided by pthreads). In order to get my library working with Valgrind with a single kernel thread, I used VALGRIND_STACK_REGISTER to register my user space stacks. However, with multiple kernel threads, I still get warnings like the following: Warning: client switching stacks? SP change: 0x418461C --> 0x597B28C Interestingly, it is complaining when I switch from a user space stack registered with VALGRIND_STACK_REGISTER back to the pthread stack. I tried "guessing" at an address range for the pthread stack, and using VALGRIND_STACK_REGISTER with it, but this caused more problems. The *real* problem I am having is that after I get the warnings, valgrind reports many of "Use of uninitialised value" errors that I don't believe. Some of the errors refer to variables allocated on the pthread stacks, which are indeed initialized. Is there some way I can tell Valgrind more about what my library is doing, in order to get it to work? It has been incredibly useful for debugging. Thanks for your help, and for the great tool, Evan Jones valgrind 3.3.0 Linux 2.6.24 Debian unstable -- Evan Jones http://evanjones.ca/ |
|
From: Nicholas N. <nj...@cs...> - 2008-05-11 23:00:59
|
On Sun, 11 May 2008, Evan Jones wrote: > I am working on a thread library that maps user space threads to kernel > threads (as provided by pthreads). In order to get my library working > with Valgrind with a single kernel thread, I used > VALGRIND_STACK_REGISTER to register my user space stacks. > > However, with multiple kernel threads, I still get warnings like the > following: > > Warning: client switching stacks? SP change: 0x418461C --> 0x597B28C > > Interestingly, it is complaining when I switch from a user space stack > registered with VALGRIND_STACK_REGISTER back to the pthread stack. I > tried "guessing" at an address range for the pthread stack, and using > VALGRIND_STACK_REGISTER with it, but this caused more problems. > > The *real* problem I am having is that after I get the warnings, > valgrind reports many of "Use of uninitialised value" errors that I > don't believe. Some of the errors refer to variables allocated on the > pthread stacks, which are indeed initialized. > > Is there some way I can tell Valgrind more about what my library is > doing, in order to get it to work? It has been incredibly useful for > debugging. I have a memory of finding some bugs in the stack registering code, but alas I cannot remember them nor find them in my notes. That might be a reason, but it might not. You could try using --max-stackframe as a workaround. Another possibility: you could modify the stack-switch detection heuristic, by assuming that if it's a constant delta that it's an allocation and thus not a stack-switch. Nick |