-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SWTException: Invalid thread access in Memory view #710
Comments
The Memory view uses a custom viewer The issue is that eclipse-platform/eclipse.platform.ui@3b9c02c changed |
My first instinct is to say that There are two fixes I can think of:
diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java
index b287456..a15ff50 100644
--- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java
+++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java
@@ -415,6 +415,11 @@
}
@Override
+ public void refresh() {
+ refresh(getRoot());
+ }
+
+ @Override
protected void internalRefresh(Object element) {
// get the nodes in the model
AsynchronousModel model = getModel(); or do a little more checking like @Bananeweizen did to fix similar issue eclipse-platform/eclipse.platform.ui#934 and add a thread check before trying to turn off redraw: diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewer.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewer.java
index e2f50da..b1d1d17 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewer.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewer.java
@@ -1421,13 +1421,13 @@
@Override
public void refresh() {
Control control = getControl();
- if (control != null) {
+ if (control != null && control.getDisplay().getThread() == Thread.currentThread()) {
control.setRedraw(false);
}
try {
refresh(getRoot());
} finally {
- if (control != null) {
+ if (control != null && control.getDisplay().getThread() == Thread.currentThread()) {
control.setRedraw(true);
}
} |
@Bananeweizen or @vogella as you both were involved with the initial change I was wondering if either of you had thoughts on this? Or anyone else wants to weigh in? |
That is different here. I wouldn't expect JFace viewer's code being called from non UI thread, that is guaranteed to fail sooner or later.
This is better, but I wonder if the code that calls refresh in the memory view should run via asyncExec() if executed from non UI thread. May be somewhere at AbstractModelProxy.fireModelChanged(). |
The entirety of that class is designed to be called asynchronously. Rewriting all its call sites seems way too much work and would largely undo the idea of the class anyway. |
I just wanted to mention that there is Display#execute that handles all the details of sync vs ansyc call depending on thread context. Beside that making the Viewer async is a bit bad idea as @iloveeclipse already mentioned, JFace is not threadsafe and as it is interacting with the SWT Thread is is mostly a good idea to only permutate anything in the SWT (UI) thread. If you like to perform certain actions in the background (e.g. loading the model), the preferred idom would be something similar to
If you like you can even use the new |
It was an interesting design decision to reuse the jface Viewer class to be asynchronous. As I look into this code further I agree that having Viewer try to maintain some undocumented feature of not touching UI thread is not a great idea. Fortunately the async viewer class hierarchy is internal to platform debug and if someone wants to refactor it one day that would be great. For now I am going to move this issue to platform as that is where platform debug ui is today and supply a PR that fixes this issues consistently with how the rest of the async viewers are written. |
The AsynchronousViewer class hierarchy reuses the Viewer interface but adds additional constraints on it, in particular it allows many of its methods to be called from non-UI threads. See javadoc summary: https://github.com/eclipse-platform/eclipse.platform/blob/e92b72761b8543358ba9811ea49807f75e98bad5/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java#L57-L59 Commit 3b9c02c added UI access to method that used to not have any, therefore this patch restores that non-UI implementation locally consistent with other methods in the async viewer that operate on the model. Fixes eclipse-platform#710
The AsynchronousViewer class hierarchy reuses the Viewer interface but adds additional constraints on it, in particular it allows many of its methods to be called from non-UI threads. See javadoc summary: https://github.com/eclipse-platform/eclipse.platform/blob/e92b72761b8543358ba9811ea49807f75e98bad5/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java#L57-L72 Commit 3b9c02c added UI access to method that used to not have any, therefore this patch restores that non-UI implementation locally consistent with other methods in the async viewer that operate on the model. Fixes eclipse-platform#710
The AsynchronousViewer class hierarchy reuses the Viewer interface but adds additional constraints on it, in particular it allows many of its methods to be called from non-UI threads. See javadoc summary: https://github.com/eclipse-platform/eclipse.platform/blob/e92b72761b8543358ba9811ea49807f75e98bad5/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java#L57-L72 Commit 3b9c02c added UI access to method that used to not have any, therefore this patch restores that non-UI implementation locally consistent with other methods in the async viewer that operate on the model. Fixes eclipse-platform#710
…pse-platform#710 The AsynchronousViewer class hierarchy reuses the Viewer interface but adds additional constraints on it, in particular it allows many of its methods to be called from non-UI threads. See javadoc summary: https://github.com/eclipse-platform/eclipse.platform/blob/e92b72761b8543358ba9811ea49807f75e98bad5/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java#L57-L72 Commit 3b9c02c added UI access to method that used to not have any, therefore this patch restores that non-UI implementation locally consistent with other methods in the async viewer that operate on the model. Fixes eclipse-platform#710
A comment on the severity of this bug, it makes 2023-09 essentially unstable for anyone who's workflow uses the memory view. Performing any edit or a memory import currently requires a manual refresh before the edited memory is shown. It is also silent unless you have the error log open so users may not realise it is a rendering issue. I am aware there is no process for building a patch release for users. But could the fix be backported to the maintenance branch? This would make it easier for those to build their own products on top of Eclipse to pick up a fix. Especially as there are other important fixes in SimRel 2023-09 & Platform 4.29 that make updating more important than usual. |
Everyone can create PRs targeting any branch.
Of course one can also simply reference the I-Build repository until it is fully released. |
The AsynchronousViewer class hierarchy reuses the Viewer interface but adds additional constraints on it, in particular it allows many of its methods to be called from non-UI threads. See javadoc summary: https://github.com/eclipse-platform/eclipse.platform/blob/e92b72761b8543358ba9811ea49807f75e98bad5/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java#L57-L72 Commit 3b9c02c added UI access to method that used to not have any, therefore this patch restores that non-UI implementation locally consistent with other methods in the async viewer that operate on the model. Fixes #710
…pse-platform#710 The AsynchronousViewer class hierarchy reuses the Viewer interface but adds additional constraints on it, in particular it allows many of its methods to be called from non-UI threads. See javadoc summary: https://github.com/eclipse-platform/eclipse.platform/blob/e92b72761b8543358ba9811ea49807f75e98bad5/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java#L57-L72 Commit 3b9c02c added UI access to method that used to not have any, therefore this patch restores that non-UI implementation locally consistent with other methods in the async viewer that operate on the model. Fixes eclipse-platform#710
…pse-platform#710 The AsynchronousViewer class hierarchy reuses the Viewer interface but adds additional constraints on it, in particular it allows many of its methods to be called from non-UI threads. See javadoc summary: https://github.com/eclipse-platform/eclipse.platform/blob/e92b72761b8543358ba9811ea49807f75e98bad5/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java#L57-L72 Commit 3b9c02c added UI access to method that used to not have any, therefore this patch restores that non-UI implementation locally consistent with other methods in the async viewer that operate on the model. Fixes eclipse-platform#710
@Kummallinen I have started backporting this to 4.29 branch in #713 |
…pse-platform#710 The AsynchronousViewer class hierarchy reuses the Viewer interface but adds additional constraints on it, in particular it allows many of its methods to be called from non-UI threads. See javadoc summary: https://github.com/eclipse-platform/eclipse.platform/blob/e92b72761b8543358ba9811ea49807f75e98bad5/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java#L57-L72 Commit 3b9c02c added UI access to method that used to not have any, therefore this patch restores that non-UI implementation locally consistent with other methods in the async viewer that operate on the model. Fixes eclipse-platform#710
This is a regression in Eclipse 4.29 compared to 4.28 - when memory view is refreshed, common after editing a cell.
This is the stacktrace:
This can easily be replicated with CDT by opening memory view, adding a memory monitor, opening a hex rendering and editing a cell.
This can also be replicated using the platform debug example PDA launch type in a dev environment
PDA Application
debug launch configuration forcounter.pda
Here is a screen recording as I am sure that some people may not know about this:
Peek.2023-09-20.16-32.mp4
The text was updated successfully, but these errors were encountered: