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

FindOverridableMethodCall detector is not thread safe #2701

Closed
iloveeclipse opened this issue Nov 15, 2023 · 0 comments · Fixed by #2702
Closed

FindOverridableMethodCall detector is not thread safe #2701

iloveeclipse opened this issue Nov 15, 2023 · 0 comments · Fixed by #2702
Assignees
Labels

Comments

@iloveeclipse
Copy link
Member

Spotbugs analysis in Eclipse can be executed on multiple projects in parallel.
In order to achieve that, detectors should not assume they run "in isolation" with a single analysis in the entire JVM.
Very basic point is not to use static storage for analysis specific data.
If they don't do that, we have errors like below:

eclipse.buildId=4.30.0.I20231114-1800
java.version=21-internal
java.vendor=N/A
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments:  -data /data/4x_platform_workspace -os linux -ws gtk -arch x86_64

com.github.spotbugs.plugin.eclipse
Error
Wed Nov 15 09:08:35 CET 2023
Exception analyzing org.eclipse.jdt.core.tests.model.IndexManagerTests using detector edu.umd.cs.findbugs.detect.FindOverridableMethodCall

java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1095)
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1049)
	at edu.umd.cs.findbugs.detect.FindOverridableMethodCall.visitBootstrapMethods(FindOverridableMethodCall.java:121)
	at org.apache.bcel.classfile.BootstrapMethods.accept(BootstrapMethods.java:82)
	at edu.umd.cs.findbugs.visitclass.PreorderVisitor.visitJavaClass(PreorderVisitor.java:408)
	at org.apache.bcel.classfile.JavaClass.accept(JavaClass.java:244)
	at edu.umd.cs.findbugs.BytecodeScanningDetector.visitClassContext(BytecodeScanningDetector.java:38)
	at edu.umd.cs.findbugs.DetectorToDetector2Adapter.visitClass(DetectorToDetector2Adapter.java:76)
	at edu.umd.cs.findbugs.FindBugs2.lambda$analyzeApplication$1(FindBugs2.java:1108)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at edu.umd.cs.findbugs.CurrentThreadExecutorService.execute(CurrentThreadExecutorService.java:86)
	at java.base/java.util.concurrent.AbstractExecutorService.invokeAll(AbstractExecutorService.java:247)
	at edu.umd.cs.findbugs.FindBugs2.analyzeApplication(FindBugs2.java:1118)
	at edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:309)
	at de.tobject.findbugs.builder.FindBugsWorker.runFindBugs(FindBugsWorker.java:314)
	at de.tobject.findbugs.builder.FindBugsWorker.work(FindBugsWorker.java:220)
	at de.tobject.findbugs.actions.FindBugsAction$StartedFromViewJob.runWithProgress(FindBugsAction.java:275)
	at de.tobject.findbugs.FindBugsJob.run(FindBugsJob.java:142)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

I will provide a simple fix.

iloveeclipse added a commit to iloveeclipse/spotbugs that referenced this issue Nov 15, 2023
Don't use static maps for analysis specific data, it can't work with
multiple analysis running in same JVM, like it might happen in Eclipse.

Fixes spotbugs#2701
@iloveeclipse iloveeclipse self-assigned this Nov 15, 2023
iloveeclipse added a commit that referenced this issue Nov 15, 2023
Don't use static maps for analysis specific data, it can't work with
multiple analysis running in same JVM, like it might happen in Eclipse.

Fixes #2701
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant