Bug 223621 - [OLE] Runtime error occurs when opener.close(); is called inside a view with OLE support or inside Intergrated Web browser
Summary: [OLE] Runtime error occurs when opener.close(); is called inside a view wit...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact: Felipe Heidrich CLA
URL:
Whiteboard: stalebug
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2008-03-24 05:34 EDT by Suneeta Mall CLA
Modified: 2020-03-09 14:30 EDT (History)
4 users (show)

See Also:


Attachments
includes sample and error screen (74.40 KB, application/octet-stream)
2008-03-24 05:34 EDT, Suneeta Mall CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Suneeta Mall CLA 2008-03-24 05:34:16 EDT
Created attachment 93256 [details]
includes sample and error screen

We are using OLE support inside Eclipse view.
Here we are getting runtime error when trying to close Parent by calling   opener.close(); twice or calling opener.focus() after the parent is closed.


steps to reproduce:

1.Modify url string (in com.hsbc.xpd.test\src\com\hsbc\xpd\test\views\TestView1.CreatePartControl()) as per the location of page1.html (in OfflineWebContent\WebContent\test\page1.html).
2. run the sample 
3. open the perspective in com.hsbc.xpd,test
4. click on open page with JS  button in page1.html
5. in child view : click on Close parent twice.
6. in second click in gives runtime error.


same is reproducible if you open the page1.html in integrated Browser.

error details are attached in the sample
Comment 1 Steve Northover CLA 2008-03-25 15:37:49 EDT
Note, this might not be SWT.  It could be the OLE support in the Workbench.
Comment 2 Duong Nguyen CLA 2008-03-25 18:22:12 EDT
I commented out the WindowClose listener to prevent the parent window from closing and pressed the Close Parent button twice and got the same crash. I'm not sure what opener.close() does?
Comment 3 Suneeta Mall CLA 2008-03-26 11:32:10 EDT
opener.close()will close the parent if parent exist.
All we are doing in addWindowClosingListner is disposing view. So thats should not be a concern when addWindowClosingListner is commented. In case of comment, the  IE which is embedded inside the olecontrolsite of the parent view will be closed but parent view will continue to exists.

opener.close() call works well in IE7 even on second hit.

I believe there is still some java code referencing to parent in COM which is causing a native exception on second hit to close parent IE(parent IE window is already disposed in first hit).
Comment 4 Suneeta Mall CLA 2008-03-27 03:37:28 EDT
New finding:
opener.close() seems to work well even on second click if the page(OfflineWebContent\WebContent\test\page1.html) is opened in Integrated Web Browser in eclipse Version: 3.3.0 Build id: I20070625-1500.  
However a crash will be observed when viewing the page in Integrated Web Browser in eclipse 3.2 .
Comment 5 Duong Nguyen CLA 2008-04-01 12:01:29 EDT
If opener.close() works in 3.3 and not 3.2 then you should upgrade to 3.3.

I don't think the javascript is correct. You are calling opener.close() when the opener has been closed and disposed. An error is reported in IE and may be this same error is causing the crash through the OLE layer. Sending any messages to a null object, a closed or disposed window will result in unpredictable (bad) results.

You should modify your script to include a "opener.closed" check:

function closewindow() {
   if (opener && !opener.closed) opener.close();
}

This fixed the problem for me. There's no plan to fix this problem.
Comment 6 Suneeta Mall CLA 2008-04-02 10:21:02 EDT
Hi Duong,
yes we figured the same workarond few days back. Thanks for your time 
Comment 7 Raji Akella CLA 2008-04-11 11:32:54 EDT
Hi Duong,
Our customer does not have control over the script and may not always be in a position to correct it. So, the workaround is not acceptable to them. We need a fix in eclipse layer to provide to the customer. Just for clarification we are using the following SWT build in our product and we see the failure there

swt.version=3.3.1.v3346jPATCH
swt.frag.linux.version=3.3.1.v3346i
swt.frag.win32.version=3.3.1.207744
Comment 8 Duong Nguyen CLA 2008-04-11 16:28:03 EDT
Can you tell me which version of IE you have on your machine? I just tried running your example with IE7 and the crash does not happen. 
Comment 9 Suneeta Mall CLA 2008-04-17 11:14:19 EDT
Hi Duoung,

My version of IE is 7. 
As reported previously, the crash is observed only when the HTML inside the view.
 The page (Page1.html) Works well in IE and integrated browser of eclipse 3.3
Comment 10 Suneeta Mall CLA 2008-04-17 11:17:52 EDT
Our focus here is to fix it for the crash in eclipse view.

Observation in other browsers were just to find a possible workaround which apprently will not work for customer this time.
Comment 11 Duong Nguyen CLA 2008-04-17 14:24:26 EDT
What I meant was that I ran your example in the Eclipse view with IE7 installed and the crash went away. This could mean that the problem can be caused below SWT by someone trying to access the disposed object.
Comment 12 Suneeta Mall CLA 2008-04-18 01:51:34 EDT
Yes, As per my understanding thats correct.
I believe, there is still soem java code referencing to already disposed parent object. This need to be taken care of and in case of native exception, that should be handled effectively. Correct me if i am wrong.
Comment 13 Suneeta Mall CLA 2008-04-18 02:06:54 EDT
Reopening the bug
Comment 14 Duong Nguyen CLA 2008-04-18 15:33:02 EDT
I'm not sure why this bug is reopened. Here are a few reason why I don't think this is an SWT problem:

1) The suggested code:

function closewindow() {
   if (opener && !opener.closed) opener.close();
}

is not a work around. If you read any javascript documentation, they all say that you should check that the opener is not null and it is open before you close it. It's standard practice and not a work around.  So to me, it's USER ERROR.

2) The problem appears to be fixed in IE7. In IE6, if the opener is null and you try to close it, you'll get an error dialog (try setting the opener to null after you close it and when you try to close again, you'll get an error dialog). However, if the opener is not null but it is closed, it crashes in IE6. IE7 handles both cases and show the user an error dialog when the opener is null or when it is closed.

3) There doesn't appear to be any evidence that the crash is occuring inside SWT code. If you look at the VM crash stack trace, the crash is occurring in mshtml.dll right after the jscript.dll is executed. The SWT code is not even close to where the crash occurred.

Stack: [0x00030000,0x00070000),  sp=0x0006b650,  free space=237k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [mshtml.dll+0xed0cc]
C  [shdocvw.dll+0x53d9f]
C  [shdocvw.dll+0x545c3]
C  [shdocvw.dll+0x565b2]
C  [mshtml.dll+0x17650c]
C  [mshtml.dll+0x17681d]
C  [mshtml.dll+0x176858]
C  [mshtml.dll+0x1701ab]
C  [mshtml.dll+0x14ec53]
C  [mshtml.dll+0xc0bc9]
C  [mshtml.dll+0x98a63]
C  [mshtml.dll+0x988ff]
C  [mshtml.dll+0x988c6]
C  [mshtml.dll+0x97d1e]
C  [jscript.dll+0x4acc]
........ about 30 calls earlier ................
C  [swt-win32-3439.dll+0x37db]
j  org.eclipse.swt.internal.win32.OS.DispatchMessageW(Lorg/eclipse/swt/internal/win32/MSG;)I+0
J  org.eclipse.swt.widgets.Display.readAndDispatch()Z

If you have any other evidence that it's SWT that's causing the crash, I will be glad to look at it.
Comment 15 Steve Northover CLA 2008-04-18 15:40:02 EDT
Suneeta, was it reopened because the work around didn't work for you?
Comment 16 Suneeta Mall CLA 2008-04-21 05:15:30 EDT
Duong, Thanks for ponting out the scenario in IE6.I didnt try it in IE6 before.
As suggetsed by you the crash happens in mshtml.DLL.

 
Steve, as described in notes mail (send to you)Its a customer issue that came to us.
Comment 17 Felipe Heidrich CLA 2009-08-13 11:11:33 EDT
Your bug has been moved to triage, visit http://www.eclipse.org/swt/triage.php for more info.
Comment 18 Leo Ufimtsev CLA 2017-08-03 12:32:20 EDT
This is a one-off bulk update. (The last one in the triage migration).

Moving bugs from swt-triaged@eclipse to platform-swt-inbox@eclipse.org and adding "triaged" keyword as per new triage process:
https://wiki.eclipse.org/SWT/Devel/Triage

See Bug 518478 for details.

Tag for notification/mail filters:
@TriageBulkUpdate
Comment 19 Eclipse Genie CLA 2020-03-09 14:30:16 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.