site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com User-agent: Thunderbird 2.0.0.9 (Windows/20071031) Kevin Van Vechten wrote: #define _XOPEN_SOURCE #include <ucontext.h> #include <stdio.h> #include <stdlib.h> void die(const char *msg) { perror(msg); exit(666); } void f() { puts("in f()!"); } int main() { char stack[4096]; 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. I don't suppose there's a way for "regular people" to see rdar data? Kind regards, Edd _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... On Jan 31, 2008, at 6:52 PM, Edd Dawson wrote: int main(void) { ucontext_t ctx; getcontext(&ctx); return 0; } edd:guff developer$ gcc getcontext.c -o getcontext -W -Wall -ansi -pedantic edd:guff developer$ ./getcontext Bus error edd:guff developer$ Why the bus error? What am I doing wrong? This is a known issue where getcontext(3) is writing past the end of the ucontext_t struct when _XOPEN_SOURCE is not defined (rdar://problem/5578699). As a workaround, define _XOPEN_SOURCE before including ucontext.h. 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. This email sent to site_archiver@lists.apple.com
participants (1)
-
Edd Dawson