Bug 545472 - Deadlock while activating diagram layer
Summary: Deadlock while activating diagram layer
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 6.0.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2019-03-17 11:55 EDT by Rolf Theunissen CLA
Modified: 2019-05-01 07:12 EDT (History)
3 users (show)

See Also:


Attachments
Stacktrace (109.35 KB, text/plain)
2019-03-17 11:55 EDT, Rolf Theunissen CLA
no flags Details
Second case of the same deadlock (6.66 KB, text/plain)
2019-03-28 12:12 EDT, Maxime Porhel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rolf Theunissen CLA 2019-03-17 11:55:27 EDT
Created attachment 277907 [details]
Stacktrace

While changing they layers on a Sirius diagram, Eclipse run into a deadlock, see the attached stack-trace.

This deadlock is cased by bug 297770, the DefaultOperationHistory keeps locks while notifying changes in the undo history.
In this case, Sirius is running updates on the UI-thread.
Simultaneous, the layer changes is handled in a separate thread. This thread acquired the undo lock, and one of the listeners tries to run something on the UI thread. However, the UI thread is still busy.
Then the UI-thread tries to acquire the undo lock, which is still hold by the other thread.

The root cause of this bug might not be in Sirius, however, it seems that Sirius tries to update the undo history from two threads when changing layers which seems incorrect too.
Comment 1 Steve Monnier CLA 2019-03-22 11:46:16 EDT
Hello,

Can you describe your odesign (or attach it here) and especially your layers? I have not been able to reproduce the deadlock and we also have JUnit and SWTBot tests that manipulates layers but does not end up in deadlock.

Thank you,
Steve
Comment 2 Rolf Theunissen CLA 2019-03-23 12:41:01 EDT
(In reply to Steve Monnier from comment #1)
> Hello,
> 
> Can you describe your odesign (or attach it here) and especially your
> layers? I have not been able to reproduce the deadlock and we also have
> JUnit and SWTBot tests that manipulates layers but does not end up in
> deadlock.
> 
> Thank you,
> Steve

Basically, by switching layers boxes are enabled/disabled within containers. I have 4 layers, that are all nested. When a layer is disabled, the nested elements are show in the 'container-container'.
The model contains about 50 containers, 100 nested at the first level, 200 and third and and about 500 nested elements at 4th level. I have observed the behavior by disabling the 2nd or 3th layer.

The deadlock does not occur all the time, so probably there is a race condition involved too.

Note that I have ELK-GMF integration installed as well (and not ELK-Sirius integration).
Comment 3 Maxime Porhel CLA 2019-03-28 12:11:38 EDT
Thanks for your detailed bug report.

We have reproduced this issue and we reckon it is valid. 

I was able to reproduce the issue without ELK but also without a clear and reproductible scenario, it is random as it depends on when each thread wants to take the lock in the default operation history and or on the ui thread.

In my case I have the command stack which has been flushed leading to a getCommand call on some GMG action which tries to access some SWT method. And on the other side I have the thread UI which is doing some async work and ties to get the Undo operation on the operation history.

See attached stack trace.



Nevertheless, it's not yet in the scope of a future release.
Comment 4 Maxime Porhel CLA 2019-03-28 12:12:22 EDT
Created attachment 278057 [details]
Second case of the same deadlock