Re: getcontext() -> Bus error?
Re: getcontext() -> Bus error?
- Subject: Re: getcontext() -> Bus error?
- From: Kevin Van Vechten <email@hidden>
- Date: Sat, 23 Feb 2008 17:16:49 -0800
On Feb 23, 2008, at 11:23 AM, Duckki Oe wrote:
I was experiencing difficulties with getcontext/makecontext last
night.
(you know.. getting SIGBUS, seg fault)
And I've figured out that Darwin's ucontext_t is not like that of
linux's.
ucontext_t on Darwin (I'm using Mac OS X 10.5.2.) does not contain
the mcontext_t,
which stores machine dependent context. And let users allocate the
mcontext_t buffer
and point it in uc_mcontext member of ucontext_t. Or it just assumes
mcontext_t buffer
follows the ucontext_t variable. You may need to look into the
actual ucontext_t structure in
/usr/include/sys/ucontext.h.
It's better to allocate ucontext_t using malloc with the length of
sizeof(ucontext_t) +
sizeof(*((mcontext_t)0)). Note that mcontext_t is just a pointer.
Now it should work fine.
This is not documented on the man pages.
On the other hand, Linux's ucontext_t CONTAINS the whole structure
of mcontext_t and
you don't have to care about additional buffer.
This was the issue I originally replied to on this thread. The
ucontext_t only includes mcontext_t when _XOPEN_SOURCE is defined
prior to including the header files (see /usr/include/sys/_structs.h).
- 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