<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Chris Danielson&#039;s Blog &#187; SIGBUS</title>
	<atom:link href="http://www.chrisdanielson.com/tag/sigbus/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chrisdanielson.com</link>
	<description>Trials and Tribulations of a Software Developer</description>
	<lastBuildDate>Wed, 14 Sep 2011 00:00:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>iPhone (SIGBUS) Issue</title>
		<link>http://www.chrisdanielson.com/2009/07/20/iphone-sigbus-issue/</link>
		<comments>http://www.chrisdanielson.com/2009/07/20/iphone-sigbus-issue/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 02:08:57 +0000</pubDate>
		<dc:creator>Chris Danielson</dc:creator>
				<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[SIGBUS]]></category>

		<guid isPermaLink="false">http://www.chrisdanielson.com/?p=26</guid>
		<description><![CDATA[If you&#8217;ve ever done any iPhone development, you&#8217;ve probably had an accident with the (nonatomic, retain) methods. These methods are difficult to use in the case where you&#8217;re working with multiple threads. Our application does not do this, but we do utilize the OpenGL ES 1.1 framework. Have a look at the following console log [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever done any iPhone development, you&#8217;ve probably had an accident with the (nonatomic, retain) methods.  These methods are difficult to use in the case where you&#8217;re working with multiple threads.  Our application does not do this, but we do utilize the OpenGL ES 1.1 framework.  Have a look at the following console log from the other night when my brother was beta testing our application with some friends at a bar.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p26code4'); return false;">View Code</a> IPHONE_CONSOLE_LOG</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p264"><td class="code" id="p26code4"><pre class="iphone_console_log" style="font-family:monospace;">Process:         myExampleApp [800]
Path:            /var/mobile/Applications/5D234CF0-1234-4E2F-9A7F-14175F39A0B6/myExampleApp.app/myExampleApp
Identifier:      myExampleApp
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]
&nbsp;
Date/Time:       2009-07-19 23:20:40.285 -0700
OS Version:      iPhone OS 3.0 (7A341)
Report Version:  104
&nbsp;
Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000008
Crashed Thread:  0
&nbsp;
Thread 0 Crashed:
0   libobjc.A.dylib                   0x30011940 objc_msgSend + 20
1   libobjc.A.dylib                   0x3001313c objc_setProperty + 160
2   myExampleApp                          0x000126e6 -[GameUIView setBasicObj:] (GameUIView.m:36)
3   myExampleApp                          0x0000f694 -[GameUIView setupView] (GameUIView.m:404)
4   myExampleApp                          0x0000ec42 -[GameUIView start] (GameUIView.m:173)
5   myExampleApp                          0x00002816 -[CoreViewController playGame] (CoreViewController.m:79)
6   myExampleApp                          0x00005e80 -[SplashGLUIView touchesEnded:withEvent:] (SplashGLUIView.m:606)
7   UIKit                             0x309a60d4 -[UIWindow _sendTouchesForEvent:] + 520
8   UIKit                             0x309a5464 -[UIWindow sendEvent:] + 108
9   UIKit                             0x30936e3c -[UIApplication sendEvent:] + 400
10  UIKit                             0x30936874 _UIApplicationHandleEvent + 4336
11  GraphicsServices                  0x32046964 PurpleEventCallback + 1028
12  CoreFoundation                    0x30254a70 CFRunLoopRunSpecific + 2296
13  CoreFoundation                    0x30254164 CFRunLoopRunInMode + 44
14  GraphicsServices                  0x3204529c GSEventRunModal + 188
15  UIKit                             0x308f0374 -[UIApplication _run] + 552
16  UIKit                             0x308eea8c UIApplicationMain + 960
17  myExampleApp                          0x000020b6 main (main.m:14)
18  myExampleApp                          0x0000202c start + 44</pre></td></tr></table></div>

<p>The core method here that is the issue is implemented as:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p26code5'); return false;">View Code</a> OBJC</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p265"><td class="code" id="p26code5"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//in the .h file.  </span>
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span style="color: #400080;">NSObject</span></a> <span style="color: #002200;">*</span>basicObj;
&nbsp;
<span style="color: #11740a; font-style: italic;">//in the .m file.</span>
<span style="color: #a61390;">@synthesize</span> basicObj;
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setupView
<span style="color: #002200;">&#123;</span>
   <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>self.basicObj <span style="color: #002200;">!=</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #002200;">&#91;</span>self.basicObj release<span style="color: #002200;">&#93;</span>;
		self.basicObj <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>; <span style="color: #11740a; font-style: italic;">//line 404, this is where the error is located.</span>
   <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>As you can see, the issue appears to be based on how we access the basicObj object.  The definition of a <a href="http://en.wikipedia.org/wiki/SIGBUS">SIGBUS</a> error, is pretty straight forward.  We are generically having some sort of memory issue.</p>
<p>As of this writing, I&#8217;m still doing extensive testing and I&#8217;ll update this post if I find a better solution.  Here is what I&#8217;ve found to work.  I&#8217;m beginning to wonder if there is a funny timing issue with the &#8220;release&#8221; methodology.  I&#8217;ll make sure to post back here if I find there to still be an issue or I find a better solution.  Comments are appreciated.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p26code6'); return false;">View Code</a> OBJC</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p266"><td class="code" id="p26code6"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setupView
<span style="color: #002200;">&#123;</span>
   <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>self.basicObj <span style="color: #002200;">!=</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #002200;">&#91;</span>basicObj release<span style="color: #002200;">&#93;</span>;
		basicObj <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.chrisdanielson.com/2009/07/20/iphone-sigbus-issue/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

