|
From: Paul H. <pa...@ha...> - 2003-11-19 13:54:00
|
On Wed, 19 Nov 2003, Lee Kindness wrote:
> Date: Wed, 19 Nov 2003 12:41:40 +0000
> From: Lee Kindness <lki...@cs...>
> To: pa...@ha...
> Cc: Lee Kindness <lki...@cs...>, val...@li...,
> Duncan Muirhead <du...@cs...>
> Subject: Re: [Valgrind-users] Nested functions
>
> Paul Haas writes:
> > Don't nest the functions and it just works.
Sorry about that comment. I realized the inappropriateness within seconds
of hitting the send button.
> Granted, but that's not really a solution. Valgrind should handle
> nested function calls. Your added debug has shown that when run under
> Valgrind the program flow is altered - I'd say that's a Valgrind bug
> and to work around it isn't the best long-term solution, afterall
> who's to say the same bug does not affect "more normal" programing
> practices?
>
> Thanks, L.
Here's a shorter program that demonstrates the same bug.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
static void CallViaP(void (*sel)(void)) {
sel();
}
int main(int argc, char** argv) {
static void MidFunc1(void) {
static void BottomFunc1(void) {
fprintf(stdout,"BottomFunc1\n");
}
CallViaP( BottomFunc1);
}
static void MidFunc2(void) {
static void BottomFunc2( void ) {
fprintf(stdout,"BottomFunc2\n");
}
CallViaP(BottomFunc2 );
}
MidFunc1();
MidFunc2();
return 0;
}
|