Re: getcontext() -> Bus error?
Re: getcontext() -> Bus error?
- Subject: Re: getcontext() -> Bus error?
- From: "Duckki Oe" <email@hidden>
- Date: Sat, 23 Feb 2008 13:23:08 -0600
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.
Duck
_______________________________________________
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