objc_collect(OBJC_EXHAUSTIVE_COLLECTION | OBJC_WAIT_UNTIL_DONE); never ends

Originator:ewmailing
Number:rdar://10660280 Date Originated:2012-01-07
Status:Open Resolved:
Product:Mac OS X Product Version:10.7.2
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Summary:
I have a reproducible case where calling
objc_collect(OBJC_EXHAUSTIVE_COLLECTION | OBJC_WAIT_UNTIL_DONE);		
will cause the application to freeze/block the application and never finish. The command never finishes executing. I must kill the application.



Steps to Reproduce:
Attached is a sample program containing LuaCocoa which can easily reproduce the problem. You must change the configuration to Release. Debug doesn't seem to do it. Build and run the SimpleLuaView project. (SimpleLuaOpenGLView will also do it).

When the application runs, it will open a window with something drawn in the view (red rectangle or yellow triangle depending on the project).

You may quit the application (Cmd-Q).
On shutdown, my code eventually calls 
objc_collect(OBJC_EXHAUSTIVE_COLLECTION | OBJC_WAIT_UNTIL_DONE);		
This is the line that things hang on.



Expected Results:
Application should quit normally.

Actual Results:
Application hangs and must be force killed.

Regression:
I think this behavior is new in 10.7. I never had this problem in 10.5 or 10.6. It seems to affect both 32-bit and 64-bit. It only affects my release builds.

Notes:

The CoreAnimationScriptiability program does not exhibit this behavior even though it calls this same method when the Lua script is closed and reopened during the run of the app.

My theory is that it has something to do with subclassing at runtime (from Lua). This is because the SimpleView applications both subclass NSView in Lua, while CoreAnimationScriptiability does no subclassing. I'm guessing the instance of the subclassed view is confusing the garbage collector and is causing the hang.




For reference, when I kill the application, I always seem to at the __psynch_cvwait in the following stack:
0x00007fff8306cbc0  <+0000>  mov    $0x2000131,%eax
0x00007fff8306cbc5  <+0005>  mov    %rcx,%r10
0x00007fff8306cbc8  <+0008>  syscall 
0x00007fff8306cbca  <+0010>  jae    0x7fff8306cbd1 <__psynch_cvwait+17>
0x00007fff8306cbcc  <+0012>  jmpq   0x7fff8306dffc <cerror>
0x00007fff8306cbd1  <+0017>  retq   
0x00007fff8306cbd2  <+0018>  nop    
0x00007fff8306cbd3  <+0019>  nop

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!