This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 532273 - [DataBinding] Race condition between Binding.doUpdate and Observable.dispose with multiple realms
Summary: [DataBinding] Race condition between Binding.doUpdate and Observable.dispose ...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.8   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Conrad Groth CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-10 11:49 EST by Conrad Groth CLA
Modified: 2020-01-13 14:27 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Conrad Groth CLA 2018-03-10 11:49:11 EST
The Binding subclasses handle observable change events in their doUpdate method. The method is called inside the source observable's realm and executes a runnable in the destination's realm. The Binding class also listens for the dipose event of both observables and handles such an event in the validation realm. Inside that realm it removes the change listener from both observables to avoid further events. But if one change event is currently pending while the destination observable gets disposed, the Runnable inside doUpdate while cause an AssertionFailedException because of the disposed Observable.

This is no theoretical problem, but it happens in my company.

The patch coming shortly will contain the fix and a test that verifies the correct behavior (and also fails without the changes).
Comment 1 Conrad Groth CLA 2018-03-10 13:29:36 EST
After more investigation the problem only seems to happen on the WritableSet, as the add method calls getterCalled() which checks the disposed state. In the WritableValue and WritableList classes the modifying operations (setValue, add, remove...) don't call getterCalled but only checkRealm. So they don't fail with an exception if a modification happens after disposing. After looking into the GIT history I see that the additional getterCalled checks in WritableSet were introduced in 2008 for bug 221351. The bug title also includes the List, so I don't know why the additional checks were only introduced for the Set.

My idea is to protect all Binding subclasses against disposed observables although List and Value currently don't have a problem.
Comment 2 Eclipse Genie CLA 2018-03-10 13:37:04 EST
New Gerrit change created: https://git.eclipse.org/r/119156
Comment 4 Karsten Thoms CLA 2018-05-09 05:31:44 EDT
Thanks, Conrad!
Comment 5 Eclipse Genie CLA 2018-05-09 11:17:18 EDT
New Gerrit change created: https://git.eclipse.org/r/122362
Comment 7 Karsten Thoms CLA 2018-05-09 12:04:19 EDT
Changes were requested and PMC approval was missing
Comment 8 Eclipse Genie CLA 2019-09-03 07:01:56 EDT
New Gerrit change created: https://git.eclipse.org/r/148775
Comment 9 Jens Lideström CLA 2019-11-16 10:49:47 EST
I plan to merge the changes to the databinding in https://git.eclipse.org/r/#/c/148775/, but without the changes to ThreadRealm.

Can anyone explain the purpose of the changes to TheadRealm? If so we can make those changes in a separate commit.
Comment 10 Conrad Groth CLA 2019-11-16 12:13:30 EST
(In reply to Jens Lideström from comment #9)
> I plan to merge the changes to the databinding in
> https://git.eclipse.org/r/#/c/148775/, but without the changes to
> ThreadRealm.
> 
> Can anyone explain the purpose of the changes to TheadRealm? If so we can
> make those changes in a separate commit.

Without the changes in ThreadRealm the added test-cases are not failing without this change.
Comment 11 Jens Lideström CLA 2019-11-16 14:53:03 EST
(In reply to Conrad Groth from comment #10)
> Without the changes in ThreadRealm the added test-cases are not failing
> without this change.

Thanks for the info, Conrad!

I'll add the changes to ThreadRealm in their own commit.

Now to try to find out why the new test is currently failing...
Comment 13 Jens Lideström CLA 2020-01-13 14:27:04 EST
I finally came around to doing this. Sorry about the delay.

Previously I ran in to some weird problems with the test, which probably only was me being confused. When I run the tests now everything works as expected:

* WITHOUT the fix in Binding and WITHOUT the changes to ThreadRealm the new test succeeds.
* WITHOUT the fix in Binding but WITH the changes to ThreadRealm the new test fails.
* WITH the fix in Binding and WITH the changes to ThreadRealm the new test succeeds.

Thanks Conrad for the fix, and especially for new test and the tricky updates to ThreadRealm!