• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: getcontext() -> Bus error?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: getcontext() -> Bus error?
      • From: Edd Dawson <email@hidden>
References: 
 >Re: getcontext() -> Bus error? (From: Edd Dawson <email@hidden>)

  • Prev by Date: Re: getcontext() -> Bus error?
  • Next by Date: Re: Leopard X11
  • Previous by thread: Re: getcontext() -> Bus error?
  • Next by thread: Re: getcontext() -> Bus error?
  • Index(es):
    • Date
    • Thread