Skip to content
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

Infinite loop in RAPDragTracker #144

Open
SOlECtiT opened this issue Sep 11, 2023 · 0 comments
Open

Infinite loop in RAPDragTracker #144

SOlECtiT opened this issue Sep 11, 2023 · 0 comments

Comments

@SOlECtiT
Copy link

Incident:
In the processing of RAPDragTracker in LightweightSystem of org.eclipse.rap.draw2d/src/org/eclipse/draw2d/LightweightSystem.java, if Canvas is forcibly terminated, processing within RAPDragTracker will loop infinitely.

Cause:
If Canvas is forcibly terminated and display.isDisposed becomes true, there is no timing to exit the while loop.

Code Snippet:

while (tracking && !cancelled) {
    if (display != null && !display.isDisposed()) {
        display.syncExec(new Runnable() {
            public void run() {
                if (canvas.isDisposed()) {
                    tracking = false;
                    cancelled = true;
                    return;
                }
                Event ev = new Event();
                //...
            }
        });
    } else {
        break;
    }
}

Thread Dump:

"Worker-6" #62 prio=5 os_prio=0 tid=0x00007f4dfc2a7800 nid=0x3d42 runnable [0x00007f4dcd14d000]
   java.lang.Thread.State: RUNNABLE
    at org.eclipse.draw2d.LightweightSystem$RAPDragTracker$1.run(LightweightSystem.java:500)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Proposed Solution:
To avoid an infinite loop, the while loop should be exited if display.isDisposed becomes true.
If display.isDisposed() becomes true, it is possible to avoid an endless loop by exiting the while loop.

if (display != null && !display.isDisposed()) {
 (omitted)
} else {
 break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant