This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 430041 - (UI)EventTopicSupplier sends events to elements of a disposed IEclipseContext
Summary: (UI)EventTopicSupplier sends events to elements of a disposed IEclipseContext
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 4.3   Edit
Hardware: PC Mac OS X
: P3 blocker (vote)
Target Milestone: 4.4 M7   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 431097
  Show dependency tree
 
Reported: 2014-03-10 15:28 EDT by Thomas Schindl CLA
Modified: 2014-04-29 09:21 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Schindl CLA 2014-03-10 15:28:09 EDT
It looks like both suppliers are sending events although the context holding them is disposed additional the UIEventObjectSupplier does not check at all of the receiver is valid
Comment 1 Thomas Schindl CLA 2014-03-10 17:24:22 EDT
Pushed JUnit-Tests to reproduce the problem at https://git.eclipse.org/r/23163 - no idea for a fix yet
Comment 2 Thomas Schindl CLA 2014-03-10 18:16:03 EDT
Initial findings is that IRequestors for objects defined using extended object suppliers are not disposed because only weaklisteners are informed about the disposal.

Generally speaking this must not be a problem but if the object only makes use of ExtendedObjectSuppliers the injector might never get informed about the context disposal.

In case one appropriately adds activeComputations & activeRATs in the list of informed objects and we explitly clear the object ref in the Requestor we don't rely on GC to clean up the weak reference.

I've pushed an updated gerrit patch - please note that the DI System is a very sensible so I'd like your input on this!
Comment 3 Thomas Schindl CLA 2014-03-11 04:21:53 EDT
Something is seriously broken in the current code base, when using extended-object-supplier and NO other *tracked* value (field/method) is injected @PreDestroy is not called.

The patch fixes this situation as well - I've updated the test suite to show the problem in action. This more and more turns out to be a really serious problem in our DI-Container which needs to be fixed to avoid leaks. 

I'm ugrading this to blocker - the only thing I'm uncertain yet is if it is a good idea to objectRef.clear() call in the Requestor another solution would be to still rely on GC and:
a) add isDisposed() API to PrimaryObjectSupplier check and make ContextObjectSupplier return false when to context is disposed
b) modify the isValid() check to take the primarySupplier state into account
Comment 4 Thomas Schindl CLA 2014-03-11 04:22:50 EDT
There's a 2nd gerrit review involved for platform-ui to check the if the requestor is still valid and unsubscribe otherwise

https://git.eclipse.org/r/23174
Comment 5 Thomas Schindl CLA 2014-03-11 04:24:32 EDT
moveing to runtime - although there are changes to UIEventTopicSupplier as well!
Comment 6 Paul Webster CLA 2014-03-11 06:04:48 EDT
Maybe we can review these at EclipseCon and get them in.

PW
Comment 7 Brian de Alwis CLA 2014-03-11 12:25:25 EDT
This is the same fix that's already in the (non-UI) EventObjectSupplier.  Thanks Tom — I had hit this before but couldn't remember the circumstances.
Comment 8 Thomas Schindl CLA 2014-03-11 12:26:33 EDT
(In reply to Brian de Alwis from comment #7)
> This is the same fix that's already in the (non-UI) EventObjectSupplier. 
> Thanks Tom — I had hit this before but couldn't remember the circumstances.

the real problem is https://git.eclipse.org/r/23163
Comment 9 Thomas Schindl CLA 2014-03-11 12:32:55 EDT
The UIEventSupplier change is merged to master - with http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=509410df493541d532bceda70924b17e83f47fb4

Still the real problem is in https://git.eclipse.org/r/23163 and the ContextSupplier / Requestor - run the JUnit-Tests to see it in action ;-)
Comment 10 Paul Webster CLA 2014-03-27 16:06:04 EDT
(In reply to Thomas Schindl from comment #8)
> 
> the real problem is https://git.eclipse.org/r/23163

Released as http://git.eclipse.org/c/platform/eclipse.platform.runtime.git/commit/?id=7882f2ee45c9b84df939928d4c0d13bceb0e0701

Thanks Tom

PW
Comment 11 Dani Megert CLA 2014-04-04 04:27:53 EDT
(In reply to Paul Webster from comment #10)
> (In reply to Thomas Schindl from comment #8)
> > 
> > the real problem is https://git.eclipse.org/r/23163
> 
> Released as
> http://git.eclipse.org/c/platform/eclipse.platform.runtime.git/commit/
> ?id=7882f2ee45c9b84df939928d4c0d13bceb0e0701
> 
> Thanks Tom
> 
> PW

This caused 2 compile warnings in the official builds.

Fixed with http://git.eclipse.org/c/platform/eclipse.platform.runtime.git/commit/?id=3c1a170e38995cd19bcc7d1a64f92c0c281adec8 and also added the missing copyright notice.
Comment 12 Paul Webster CLA 2014-04-29 09:21:11 EDT
In 4.4.0.I20140428-2000

PW