|
From: Christoph B. <bar...@or...> - 2008-03-30 18:40:44
|
Am Sonntag, 30. März 2008 schrieb Michael Baker: be the case that valgrind has problems with > > user contexts. > > Christoph, > > I'd happily show the code but that could represent a problem for many > reasons. Potentially interstingly, I've also tried a simple swapcontext > example and valgrind reports no problems. > > /MikeB I do not think that a simple routine linke StartCoroutineWithParameters could result in legal problems. Christoph |
|
From: Michael B. <mi...@ob...> - 2008-03-31 07:37:32
|
> -----Original Message----- > From: Christoph Bartoschek [mailto:bar...@or...] > Sent: 30 March 2008 19:41 > > I do not think that a simple routine linke > StartCoroutineWithParameters could result in legal problems. Cristoph, thanks for the advice but nevertheless I'm reluctant to post the code as the function you mention has many dependencies, most of which affect the data structures that represent the coroutines. Because of that, I'm pretty sure that I'd have to post the whole source file (all 3200+ lines of it). As you've intimated, I am concerned about legal aspects of posting this code as it just doesn't belong to me. It belongs to a client of a client who is a large pharmaceutical company. They have large wallets and teams of lawyers. I am interested in the reasons you highlighted StartCoroutineWithParameters. Was that just because StartCoroutineWithParameters is the function that calls swapcontext or was there some other reason based upon your experience of this particular valgrind error? Regards, /MikeB |
|
From: Christoph B. <bar...@or...> - 2008-03-31 09:01:58
|
Am Montag, 31. März 2008 schrieb Michael Baker: > > I am interested in the reasons you highlighted > StartCoroutineWithParameters. Was that just because > StartCoroutineWithParameters is the function that calls swapcontext or was > there some other reason based upon your experience of this particular > valgrind error? If valgrind has a problem with swapcontext, then you would need debug symbols for your glibc and the source code. If valgrind has no problems with swapcontext, then the only reason for valgrind to complain within swapcontext is invalid data passed to swapcontext directly or indirectly. You could start by checking whether the structures given to swapcontext are defined. Christoph |
|
From: Michael B. <mi...@ob...> - 2008-04-01 08:00:42
|
In my original post, part of the valgrind message included the following
line:
==17663== Warning: client switching stacks? SP change: 0xBEEEC18C -->
0x401BD64
Now, I have a very simple demo program that switches context using
swapcontext but valgrind doesn't display the warning when I run the demo. I
certainly would expect my demo code to cause the stack to switch so I'm a
little surprised that I don't see the warning.
Maybe I misunderstand the warning message and I shouldn't expect to see it.
Can anyone shed any light on what the message means and why I don't see it
in the demo?
I've dumped the code of my demo into this email below.
Regards,
MikeB
#include <assert.h>
#include <stdio.h>
#include <ucontext.h>
static ucontext_t currentContext_;
static ucontext_t coroutine1Context_;
static int coroutine1Counter_ = 0;
static ucontext_t coroutine2Context_;
static int coroutine2Counter_ = 0;
void coroutine1(void)
{
while( coroutine1Counter_ < 10)
{
++coroutine1Counter_;
swapcontext(&coroutine1Context_, &coroutine2Context_);
}
}
void coroutine2(void)
{
while( coroutine2Counter_ < 10)
{
++coroutine2Counter_;
swapcontext(&coroutine2Context_, &coroutine1Context_);
}
}
int main (void)
{
char coroutine1Stack[8192];
char coroutine2Stack[8192];
getcontext(&coroutine1Context_);
coroutine1Context_.uc_stack.ss_sp = coroutine1Stack;
coroutine1Context_.uc_stack.ss_size = sizeof coroutine1Stack;
coroutine1Context_.uc_link = ¤tContext_;
makecontext(&coroutine1Context_, coroutine1, 0);
getcontext(&coroutine2Context_);
coroutine2Context_.uc_stack.ss_sp = coroutine2Stack;
coroutine2Context_.uc_stack.ss_size = sizeof coroutine2Stack;
coroutine2Context_.uc_link = &coroutine1Context_;
makecontext(&coroutine2Context_, coroutine2, 0);
swapcontext(¤tContext_, &coroutine1Context_);
if( coroutine1Counter_ == 10 && coroutine1Counter_ ==
coroutine2Counter_)
{
printf("Success!\n");
}
return 0;
}
|
|
From: Christoph B. <bar...@or...> - 2008-04-01 09:44:51
|
Am Dienstag, 1. April 2008 schrieb Michael Baker: > ==17663== Warning: client switching stacks? SP change: 0xBEEEC18C --> > 0x401BD64 The change from 0xBEEEC18C to 0x401BD64 seems to be quite high for me. The target address might be corrupted. Did you check the values of your contexts? VALGRIND_CHECK_MEM_IS_DEFINED(*contextpointer, sizeof(struct ucontext)); Christoph |