<div dir="ltr"><div>I have a Cocoa application built with Clozure and the Objective-C bridge that has been developed over the course of ccl-1.8-ccl-2.0 and OS X 10.6.8 - OS X 10.9.2. It seems that every time I upgrade OS X I find new areas of the code that use the Objective-C bridge that crash due to not being thread safe. Basically, I have to identify new areas in the code that I need to wrap with '(easygui::running-on-main thread () ...)' in order to keep things from crashing.</div>
<div><br></div><div>On the one hand, I'm happy that my testing environment works well enough to identify these new issues during testing. On the other hand, it's not very satisfying to have the tests fail every time I upgrade OS X due to new threading issues. </div>
<div><br></div><div>I would like to be able to better identify areas in the code that might have threading issues (i.e., that need to be run on the GUI thread), so that I can clean things up before tests start to fail, so that I have a better chance to have an error-free upgrade when moving to a new OS X version.</div>
<div><br></div><div>For developers with a lot of experience with Cocoa/Objective-C/Clozure, how have you identified these areas? Are there any static/dynamic analysis tools or debugging flags that can identify trouble spots before crashes happen?</div>
<div><br></div><div>If you identify trouble spots by simply running the code and testing (like I'm doing currently), when a crash occurs, how do you troubleshoot where the threading issue lies? On my setup when a threading issue occurs, I do not get very informative feedback; the GUI thread hangs, the slime thread seems to hang, I don't see anything useful in Console.app, etc. So it's basically just divide-and-conquer of the testing code (and restarting slime/:cocoa each time, grrr) until I can identify the trouble area.</div>
<div><br></div><div>Maybe the 'right' way is for me to better understand how cocoa works, so that I can use that conceptual understanding to have a better sense where trouble spots might be when writing code. If that's the case, recommendations on reading material would be very helpful.</div>
<div><br></div><div>Thanks for the tips,</div><div>-Clayton</div><div><br></div><div><br></div></div>