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

> #3339 NPE caused by null defaultImage in XtextEditorTickUpdater (updateEditorImage) #3340

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mehmet-karaman
Copy link
Contributor

@mehmet-karaman mehmet-karaman commented Feb 7, 2025

Set fields to volatile which could possible be accessed by multiple threads. Used local variables to store the value and added check with local variable.

@cdietrich
Copy link
Contributor

can you also have a look at the subclasses

@mehmet-karaman
Copy link
Contributor Author

mehmet-karaman commented Feb 7, 2025

There is only one subclass (XtendEditorErrorTickUpdater), which has only one field and that is not set to null..

@mehmet-karaman
Copy link
Contributor Author

Ah .. I've got it.. Classes which implement this interface IXtextEditorCallback :)

Copy link

github-actions bot commented Feb 7, 2025

Test Results

  6 461 files  ±0    6 461 suites  ±0   3h 21m 31s ⏱️ + 3m 32s
 43 241 tests ±0   42 657 ✅ ±0    584 💤 ±0  0 ❌ ±0 
170 051 runs  ±0  167 714 ✅ ±0  2 337 💤 ±0  0 ❌ ±0 

Results for commit fc5f46d. ± Comparison against base commit d3d2755.

♻️ This comment has been updated with latest results.

@mehmet-karaman mehmet-karaman force-pushed the 3339_NPE_caused_by_null_defaultImage_in_XtextEditorTickUpdater branch from 3df46c9 to e9d5e0f Compare February 7, 2025 12:28
@mehmet-karaman
Copy link
Contributor Author

Found one more case, where this could happen.. OverrideIndicatorModelListener uses the editor, which is unset and its not volatile.. I've also used it as local variable to avoid setting to null afterwards..

@cdietrich
Copy link
Contributor

no i mean the xtend one. do we need the local stuff you do there too

@mehmet-karaman
Copy link
Contributor Author

Oh now I looked again, the changes in the "OverrideIndicatorModelListener" are not necessary, because the field is accessed only in the UI thread.. So no worker thread should execute this code..

The problem happens only if the UI thread calls the beforeDispose, meanwhile a worker thread accesses the fields which are set by the beforeDispose method to null. If you check the stacktrace in the ticket, you will see that the defaultImage is accessed by the worker thread, where the UI thread already set this defaultImage to null..

@mehmet-karaman
Copy link
Contributor Author

We can keep the changes.. Maybe there is a worker thread which does the same for the next time.. So It shouldn't harm to keep these changes..

@mehmet-karaman mehmet-karaman marked this pull request as ready for review February 7, 2025 21:34
@mehmet-karaman mehmet-karaman force-pushed the 3339_NPE_caused_by_null_defaultImage_in_XtextEditorTickUpdater branch from e9d5e0f to ba50210 Compare February 9, 2025 13:02
@mehmet-karaman
Copy link
Contributor Author

I've done a rebase.

@iloveeclipse
Copy link
Contributor

@mehmet-karaman : could you please check what is wrong with your commit metadata (autor mail seem not match one expected by ECA)?

@mehmet-karaman mehmet-karaman force-pushed the 3339_NPE_caused_by_null_defaultImage_in_XtextEditorTickUpdater branch from ba50210 to c37ac09 Compare February 10, 2025 08:37
@mehmet-karaman
Copy link
Contributor Author

eclipsefdn/eca problem seems to be fixed.

@mehmet-karaman mehmet-karaman force-pushed the 3339_NPE_caused_by_null_defaultImage_in_XtextEditorTickUpdater branch from c37ac09 to fc5f46d Compare February 10, 2025 08:39
@mehmet-karaman
Copy link
Contributor Author

@cdietrich are we done here?

@cdietrich
Copy link
Contributor

i have no time to try

@LorenzoBettini
Copy link
Contributor

I'm not very familiar with this part of the code base.
If that's related to a bug, I can try to reproduce the bug as long as I'm given the detailed steps and verify that this PR fixes the bug.
Otherwise, @szarnekow may judge better than I do.
In general, I think the PR is OK.

@iloveeclipse
Copy link
Contributor

Originally this bug was reported during our automated tests and from the stack trace it was almost obvious why that happened, since the test opens/closes Xtext editor and the background job simply runs after editor was already disposed.

I haven't tried, but to reproduce one should create breakpoint at the job code (XtextEditorErrorTickUpdater.modelChanged()) that runs while changing some text in Xtext based editor, change the text, close the editor and let the job continue. If that doesn't sow the problem, the text should be changed outside of the editor so we have a resource change.

IMHO the code was buggy and the fix is more or less trivial.

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

Successfully merging this pull request may close these issues.

4 participants