Re: getcontext() -> Bus error?
Re: getcontext() -> Bus error?
- Subject: Re: getcontext() -> Bus error?
- From: Kevin Van Vechten <email@hidden>
- Date: Sun, 03 Feb 2008 18:25:37 -0800
On Feb 3, 2008, at 4:43 PM, Edd Dawson wrote:
That seems to have stopped the bus error -- thanks! -- but now I'm
getting what I believe is fishy behaviour from swapcontext(). The
following program prints "about to swapcontext()..." indefinitely.
The 4096-byte stack storage provided is too small for Darwin. The
stack size should be at least MINSIGSTKSZ (include signal.h to get
this constant).
#define _XOPEN_SOURCE
#include <ucontext.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
void die(const char *msg)
{
perror(msg);
exit(666);
}
void f()
{
puts("in f()!");
}
int main()
{
char stack[MINSIGSTKSZ];
ucontext_t ctx;
ucontext_t ctx2;
if (getcontext(&ctx) == -1)
die("getcontext failed\n");
if (getcontext(&ctx2) == -1)
die("getcontext failed\n");
ctx2.uc_stack.ss_sp = stack;
ctx2.uc_stack.ss_size = sizeof stack;
ctx2.uc_link = 0;
makecontext(&ctx2, &f, 0);
puts("about to swapcontext()...");
if (swapcontext(&ctx, &ctx2) == -1)
die("swapcontext failed\n");
return 0;
}
Again, this behaves as expected on my Linux machine.
And with the above changes, this should work as expected on Darwin as
well. =)
I don't suppose there's a way for "regular people" to see rdar data?
No, there isn't.
- Kevin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden