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

[bndtools] Need -include loop detection #5336

Closed
kriegfrj opened this issue Aug 10, 2022 · 1 comment · Fixed by #5391
Closed

[bndtools] Need -include loop detection #5336

kriegfrj opened this issue Aug 10, 2022 · 1 comment · Fixed by #5391
Assignees
Milestone

Comments

@kriegfrj
Copy link
Contributor

In 6.4.0.202206161450-SNAPSHOT of Bndtools:

I got a StackOverflowError:

!ENTRY bndtools.core 4 0 2022-08-10 09:24:51.948
!MESSAGE Error in run listener
!STACK 0
java.lang.StackOverflowError
	at java.base/java.util.regex.Pattern$GroupHead.match(Pattern.java:4789)
	at java.base/java.util.regex.Pattern$NotBehind.match(Pattern.java:5290)
	at java.base/java.util.regex.Pattern$Start.match(Pattern.java:3608)
	at java.base/java.util.regex.Matcher.search(Matcher.java:1728)
	at java.base/java.util.regex.Matcher.find(Matcher.java:745)
	at java.base/java.util.regex.Pattern.split(Pattern.java:1265)
	at aQute.bnd.osgi.Macro.getMacro(Macro.java:211)
	at aQute.bnd.osgi.Macro.getMacro(Macro.java:200)
	at aQute.bnd.osgi.Processor.getLiteralProperty(Processor.java:1099)
	at aQute.bnd.osgi.Processor.getProperty(Processor.java:1052)
	at aQute.bnd.osgi.Processor.getProperty(Processor.java:1044)
	at aQute.bnd.osgi.Processor.getProperty(Processor.java:1040)
	at aQute.bnd.osgi.Processor.isFailOk(Processor.java:542)
	at aQute.bnd.osgi.Processor.error(Processor.java:285)
	at aQute.bnd.osgi.Processor.doIncludeFile(Processor.java:870)
	at aQute.bnd.osgi.Processor.doIncludeFile(Processor.java:858)
	at aQute.bnd.osgi.Processor.doIncludes(Processor.java:842)
	at aQute.bnd.osgi.Processor.doIncludeFile(Processor.java:883)
	at aQute.bnd.osgi.Processor.doIncludeFile(Processor.java:858)
	at aQute.bnd.osgi.Processor.doIncludes(Processor.java:842)
	at aQute.bnd.osgi.Processor.doIncludeFile(Processor.java:883)
	at aQute.bnd.osgi.Processor.doIncludeFile(Processor.java:858)
	at aQute.bnd.osgi.Processor.doIncludes(Processor.java:842)
       ...

Not exactly sure how it happened, but it was after I had manipulated a .bndrun file. I had:

  • base.bndrun
  • server.bndrun
  • server-dev.bndrun

server.bndrun includes base.bndrun. server-dev.bndrun started off life as a clone of server.bndrun (and hence also included base.bndrun). The last change I made before the stack overflow was to change server-dev's include statement to include server.bndrun instead of base.bndrun.

Eclipse recommended that I restart the Workbench, which I did. The StackOverflow happened again on restart. Instead of answering "Yes" to the "do you want to exit" question, I closed the bndrun editor. Seems to be stable now.

Possibly related: found this in the error log afterward:

java.lang.NullPointerException: Cannot invoke "aQute.bnd.build.Run.getPropertiesFile()" because "run" is null
	at bndtools.m2e.MavenRunListenerHelper.getResource(MavenRunListenerHelper.java:42)
	at bndtools.m2e.MavenImplicitProjectRunListener.end(MavenImplicitProjectRunListener.java:19)
	at bndtools.launch.util.LaunchUtils.endRun(LaunchUtils.java:113)
	at bndtools.editor.BndEditor.dispose(BndEditor.java:724)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.invalidate(CompatibilityPart.java:264)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.destroy(CompatibilityPart.java:421)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:995)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:960)
	at org.eclipse.e4.core.internal.di.InjectorImpl.uninject(InjectorImpl.java:201)
	at org.eclipse.e4.core.internal.di.Requestor.uninject(Requestor.java:177)
	at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:89)
	at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:103)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.removeListenersTo(EclipseContext.java:485)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.uninject(ContextInjectionFactory.java:184)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:947)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:861)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:845)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.subscribeTopicToBeRendered(PartRenderingEngine.java:185)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.di.internal.extensions.EventObjectSupplier$DIEventHandler.handleEvent(EventObjectSupplier.java:92)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:205)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:203)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:133)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:75)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:44)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:55)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:63)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
	at org.eclipse.e4.ui.model.application.ui.impl.UIElementImpl.setToBeRendered(UIElementImpl.java:314)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.hidePart(PartServiceImpl.java:1401)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.hidePart(PartServiceImpl.java:1331)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.closePart(StackRenderer.java:1182)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer$3.close(StackRenderer.java:1042)
	at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1961)
	at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:336)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4251)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4068)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3645)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1467)

I suspect the above NPE occured because of the StackOverflow, the workspace object failed to initialise properly, eg per this log message:

!ENTRY org.eclipse.m2e.logback.appender 4 0 2022-08-10 09:24:51.948
!MESSAGE onAnyWorkspace callback failed
!STACK 0
java.lang.Exception: Cannot load Bnd project for directory D:/workspace/idempiere-plugins/idempiere-server/server.bndrun: no Bnd workspace found
	at bndtools.launch.util.LaunchUtils.createRun(LaunchUtils.java:85)
	at bndtools.editor.BndEditor.loadEditModel(BndEditor.java:618)
	at bndtools.editor.BndEditor.lambda$init$0(BndEditor.java:566)
	at org.osgi.util.promise.DeferredPromiseImpl$ThenAccept.accept(DeferredPromiseImpl.java:433)
	at org.osgi.util.promise.DeferredPromiseImpl.result(DeferredPromiseImpl.java:151)
	at org.osgi.util.promise.DeferredPromiseImpl$ThenAccept.run(DeferredPromiseImpl.java:426)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
@kriegfrj kriegfrj changed the title [m2e] StackOverflow, NPE logged in bndtools [bndtools] Need -include loop detection Aug 10, 2022
@kriegfrj
Copy link
Contributor Author

I just figured out the problem: I thought I had modified server-dev.bndrun to include server.bndrun. Turns out I had modified server.bndrun to include server.bndrun, so it was including itself.

It would be good to have some loop detection in the BndEditModel.

@bjhargrave bjhargrave added this to the 6.4 milestone Sep 2, 2022
pkriens added a commit to pkriens/bnd that referenced this issue Oct 6, 2022
The problem was that there was no test cases. There
actually was a loop detection. I already was incredibly
surprised because I am pretty sure I wrote this code
and forgetting to check cycles is even beneath me.However,
I'd forgotten to add a return after the error message ...

So the code continued forever to include the same
file anyway although dutifully reporting it.

Fixes bndtools#5336

Signed-off-by: Peter Kriens <Peter.Kriens@aqute.biz>
pkriens added a commit that referenced this issue Oct 7, 2022
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 a pull request may close this issue.

3 participants