[Gluster-devel] glusterd crashes when synctask is used in conjunction with inner functions.
Krishnan Parthasarathi
kparthas at redhat.com
Mon Oct 8 18:43:53 UTC 2012
I tried the experiment you had suggested. The following are the
changes I made to 'inner' function to take a single integer arg.
On compiling (gcc inner.c) and running, I didn't see any crash :(
--- inner.c 2012-10-09 00:06:53.799244495 +0530
+++ inner.c1 2012-10-09 00:06:34.173211036 +0530
@@ -1,6 +1,6 @@
#include <stdio.h>
-typedef void print_fn (void);
+typedef void print_fn (int);
print_fn *my_print_fn;
@@ -10,14 +10,14 @@
int outer_val = 0x5678;
void
- inner (void)
+ inner (int a)
{
- printf("in inner function, result = 0x%x\n",outer_val);
+ printf("in inner function, result = 0x%x:%x\n",outer_val, a);
}
printf("in outer function\n");
- inner();
+ inner(outer_val);
my_print_fn = &inner;
}
@@ -36,7 +36,7 @@
if (argc > 1) {
rewrite_stack();
}
- (*my_print_fn)();
+ (*my_print_fn)(0x42);
return 0;
}
----- Original Message -----
> From: "Jeff Darcy" <jdarcy at redhat.com>
> To: gluster-devel at nongnu.org
> Sent: Monday, October 8, 2012 11:31:33 PM
> Subject: Re: [Gluster-devel] glusterd crashes when synctask is used in conjunction with inner functions.
>
> OK, I couldn't resist. I've attached an inner-function test program
> which
> weakly confirms my theory. If you run it with no arguments, the
> inner function
> works. If you run it with arguments, this causes the stack to be
> reused and
> that seems to include the "thunk" I mentioned. The result is a jump
> into
> nowhere, followed by SIGSEGV or SIGILL (oddly I've seen both). If it
> fails in
> the outer-function-return case, I'll bet it fails with ucontext
> trickery too.
>
> http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html
> http://stackoverflow.com/questions/2929281/are-nested-functions-a-bad-thing-in-gcc
>
>
> _______________________________________________
> Gluster-devel mailing list
> Gluster-devel at nongnu.org
> https://lists.nongnu.org/mailman/listinfo/gluster-devel
>
More information about the Gluster-devel
mailing list