Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 335613

Summary: Infinite loop after setFocus / screensaver interaction
Product: [Eclipse Project] Platform Reporter: Greg Smith <gregsmit>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: mpcarl, skovatch
Version: 3.6.1   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Apple crash report showing infinite loop in SWT none

Description Greg Smith CLA 2011-01-27 15:44:59 EST
Build Identifier: 3.6.1.v3655c

Our Eclipse based application was running when the screen saver on Mac OS X locked after a couple of minutes of activity.

When the user came back, and unlocked the screensaver, the application crashed with a Apple crash report.  When looking at the crash report, its clear that there is a never ending loop in the stack, that looks like this:

j  org.eclipse.swt.internal.carbon.OS.SelectWindow(I)V+0
j  org.eclipse.swt.widgets.Shell.setActive()V+16
j  org.eclipse.swt.widgets.Shell.bringToTop(Z)V+20
j  org.eclipse.swt.widgets.Control.forceFocus()Z+60
j  org.eclipse.swt.widgets.Control.setTabItemFocus()Z+10
j  org.eclipse.swt.widgets.Control.setTabGroupFocus()Z+1
j  org.eclipse.swt.widgets.Control.traverseGroup(Z)Z+93
j  org.eclipse.swt.widgets.Shell.kEventWindowActivated(III)I+169
J  org.eclipse.swt.widgets.Widget.windowProc(III)I
J  org.eclipse.swt.widgets.Display.windowProc(III)I
v  ~StubRoutines::call_stub
j  org.eclipse.swt.internal.carbon.OS.SelectWindow(I)V+0
j  org.eclipse.swt.widgets.Shell.setActive()V+16
j  org.eclipse.swt.widgets.Shell.bringToTop(Z)V+20
j  org.eclipse.swt.widgets.Control.forceFocus()Z+60
j  org.eclipse.swt.widgets.Control.setTabItemFocus()Z+10
j  org.eclipse.swt.widgets.Control.setTabGroupFocus()Z+1
j  org.eclipse.swt.widgets.Control.traverseGroup(Z)Z+93
j  org.eclipse.swt.widgets.Shell.kEventWindowActivated(III)I+169
J  org.eclipse.swt.widgets.Widget.windowProc(III)I
J  org.eclipse.swt.widgets.Display.windowProc(III)I
v  ~StubRoutines::call_stub

This is repeated 100s of times.  

The root cause, at the very bottom of the stack, is a call to setFocus() on the Window.

The problem is intermittent -- and not easy to reproduce.

The Apple crash stack will be attached.

Reproducible: Always

Steps to Reproduce:
Difficult to reproduce, but the application crash stack has been recorded.

To reproduce, setFocus must be called at exactly the correct time as when the screensaver is locking.
Comment 1 Greg Smith CLA 2011-01-27 15:48:41 EST
Created attachment 187775 [details]
Apple crash report showing infinite loop in SWT

Apple crash report showing infinite loop in SWT
Comment 2 Scott Kovatch CLA 2011-02-04 13:03:10 EST
Amazingly enough, this is the same problem we're fixing in bug 329872. Calling SelectWindow, presumably when the application is not currently active, leads to an infinite loop.

That might be a better fix than the one I wrote, but in any event the stack is the same.

*** This bug has been marked as a duplicate of bug 329872 ***