From mboxrd@z Thu Jan 1 00:00:00 1970 Mime-Version: 1.0 (Apple Message framework v753.1) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: Russ Cox Content-Transfer-Encoding: 7bit From: Josh Wood Subject: Re: [9fans] 9vx native OS X gui Date: Sun, 29 Jun 2008 07:55:45 -0700 To: 9fans@9fans.net Topicbox-Message-UUID: cb6bb834-ead3-11e9-9d60-3106f5b1d025 > I assume the fix would be to install an EXC_BAD_ACCESS > handler after kicking off the app event loop. That would > make sure that Carbon never saw it. > But I don't know how to do that. I don't have a 10.5 mac to see if this is moot with the changes to CrashReporter.app. mach/mach.h has thread_set_exception_ports() to install handlers for mach exceptions. There is also a task_ version for all the threads in a task. The basics are like: /* recieve right */ kret = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECIEVE, &exception_port); /* send right */ kret = mach_port_insert_right(mach_task_self(), exception_port, exception_port, MACH_MSG_TYPE_MAKE_SEND); /* select exc type */ kret = thread_set_exception_ports(mach_thread_self(), EXC_MASK_BAD_ACCESS, exception_port, EXCEPTION_DEFAULT, THEAD_STATE_NONE); Then you do what you want with the exception; in the common case that means set up fake sigcontext and deliver to signal handler code. Amit Singh's osx kernel book has example code (http://macosxbook.com/ book/src/ in fig. 9-38). http://tinyurl.com/46dsgp is a production example with comments @ the phrase ``Mach's exception mechanism''. It's Apple's bug, and that's too far to have to go to work around it, IMO, but the technique might be interesting or handy for this kind of software atop osx. -Josh