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

OSATE editor crashes with index out of bounds exception with model using behavior annex #2065

Closed
smithdtyler opened this issue Nov 18, 2019 · 7 comments
Assignees
Milestone

Comments

@smithdtyler
Copy link

@smithdtyler smithdtyler commented Nov 18, 2019

Summary

The xtext editor crashes hard when the behavior annex is used with features, displaying only "Index: 0, Size: 0"

Expected and Current Behavior

Expected: Show the AADL model.

Actual:

Screen Shot 2019-11-18 at 2 28 59 PM

Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.rangeCheck(ArrayList.java:653)
	at java.util.ArrayList.get(ArrayList.java:429)
	at org.osate.ba.analyzers.AadlBaTypeChecker.dispatchTriggerResolver(AadlBaTypeChecker.java:576)
	at org.osate.ba.analyzers.AadlBaTypeChecker.dispatchTriggerConditionCheck(AadlBaTypeChecker.java:514)
	at org.osate.ba.analyzers.AadlBaTypeChecker.dispatchConditionCheck(AadlBaTypeChecker.java:392)
	at org.osate.ba.analyzers.AadlBaTypeChecker.behaviorTransitionCheck(AadlBaTypeChecker.java:360)
	at org.osate.ba.analyzers.AadlBaTypeChecker.checkTypes(AadlBaTypeChecker.java:154)
	at org.osate.ba.AadlBaResolver.resolveAnnex(AadlBaResolver.java:86)
	at org.osate.annexsupport.AnnexResolverProxy.resolveAnnex(AnnexResolverProxy.java:70)
	at org.osate.xtext.aadl2.parsing.AnnexParserAgent.processAnnexSection(AnnexParserAgent.java:226)
	at org.osate.xtext.aadl2.parsing.AnnexParserAgent.afterModelLinked(AnnexParserAgent.java:138)
	at org.eclipse.xtext.linking.impl.AbstractCleaningLinker.linkModel(AbstractCleaningLinker.java:57)
	at org.eclipse.xtext.resource.XtextResource.doLinking(XtextResource.java:340)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLinking(LazyLinkingResource.java:121)
	at org.eclipse.xtext.resource.XtextResource.updateInternalState(XtextResource.java:301)
	at org.eclipse.xtext.resource.DerivedStateAwareResource.updateInternalState(DerivedStateAwareResource.java:170)
	at org.eclipse.xtext.resource.XtextResource.updateInternalState(XtextResource.java:290)
	at org.eclipse.xtext.resource.DerivedStateAwareResource.updateInternalState(DerivedStateAwareResource.java:162)
	at org.eclipse.xtext.resource.XtextResource.doLoad(XtextResource.java:180)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLoad(LazyLinkingResource.java:114)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1563)
	at org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.loadResource(XtextDocumentProvider.java:246)
	at org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.setDocumentResource(XtextDocumentProvider.java:216)
	... 120 more
!SUBENTRY 1 org.eclipse.xtext.ui 4 0 2019-11-18 14:20:04.006
!MESSAGE Index: 0, Size: 0
!STACK 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.rangeCheck(ArrayList.java:653)
	at java.util.ArrayList.get(ArrayList.java:429)
	at org.osate.ba.analyzers.AadlBaTypeChecker.dispatchTriggerResolver(AadlBaTypeChecker.java:576)
	at org.osate.ba.analyzers.AadlBaTypeChecker.dispatchTriggerConditionCheck(AadlBaTypeChecker.java:514)
	at org.osate.ba.analyzers.AadlBaTypeChecker.dispatchConditionCheck(AadlBaTypeChecker.java:392)
	at org.osate.ba.analyzers.AadlBaTypeChecker.behaviorTransitionCheck(AadlBaTypeChecker.java:360)
	at org.osate.ba.analyzers.AadlBaTypeChecker.checkTypes(AadlBaTypeChecker.java:154)
	at org.osate.ba.AadlBaResolver.resolveAnnex(AadlBaResolver.java:86)
	at org.osate.annexsupport.AnnexResolverProxy.resolveAnnex(AnnexResolverProxy.java:70)
	at org.osate.xtext.aadl2.parsing.AnnexParserAgent.processAnnexSection(AnnexParserAgent.java:226)
	at org.osate.xtext.aadl2.parsing.AnnexParserAgent.afterModelLinked(AnnexParserAgent.java:138)
	at org.eclipse.xtext.linking.impl.AbstractCleaningLinker.linkModel(AbstractCleaningLinker.java:57)
	at org.eclipse.xtext.resource.XtextResource.doLinking(XtextResource.java:340)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLinking(LazyLinkingResource.java:121)
	at org.eclipse.xtext.resource.XtextResource.updateInternalState(XtextResource.java:301)
	at org.eclipse.xtext.resource.DerivedStateAwareResource.updateInternalState(DerivedStateAwareResource.java:170)
	at org.eclipse.xtext.resource.XtextResource.updateInternalState(XtextResource.java:290)
	at org.eclipse.xtext.resource.DerivedStateAwareResource.updateInternalState(DerivedStateAwareResource.java:162)
	at org.eclipse.xtext.resource.XtextResource.doLoad(XtextResource.java:180)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLoad(LazyLinkingResource.java:114)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1563)
	at org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.loadResource(XtextDocumentProvider.java:246)
	at org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.setDocumentResource(XtextDocumentProvider.java:216)
	at org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.setDocumentContent(XtextDocumentProvider.java:194)
	at org.eclipse.ui.editors.text.StorageDocumentProvider.createDocument(StorageDocumentProvider.java:225)
	at org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.createDocument(XtextDocumentProvider.java:149)
	at org.eclipse.ui.editors.text.FileDocumentProvider.createElementInfo(FileDocumentProvider.java:691)
	at org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.createElementInfo(XtextDocumentProvider.java:270)
	at org.eclipse.ui.texteditor.AbstractDocumentProvider.connect(AbstractDocumentProvider.java:395)
	at org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput(AbstractTextEditor.java:4212)
	at org.eclipse.ui.texteditor.StatusTextEditor.doSetInput(StatusTextEditor.java:260)
	at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.doSetInput(AbstractDecoratedTextEditor.java:1478)
	at org.eclipse.ui.editors.text.TextEditor.doSetInput(TextEditor.java:153)
	at org.eclipse.xtext.ui.editor.XtextEditor.doSetInput(XtextEditor.java:259)
	at org.eclipse.ui.texteditor.AbstractTextEditor.lambda$1(AbstractTextEditor.java:3179)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:436)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:352)
	at org.eclipse.ui.internal.WorkbenchWindow.lambda$5(WorkbenchWindow.java:2368)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:72)
	at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2366)
	at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3196)
	at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3221)
	at org.eclipse.xtext.ui.editor.XtextEditor.init(XtextEditor.java:305)
	at org.eclipse.ui.internal.EditorReference.initialize(EditorReference.java:353)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:340)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:998)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:963)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalInject(InjectorImpl.java:139)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:408)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:331)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:202)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:91)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:60)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:42)
	at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:132)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:1002)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:662)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:768)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:739)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:733)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:717)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1293)
	at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.lambda$0(LazyStackRenderer.java:75)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.lambda$0(UIEventHandler.java:38)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:236)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:146)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4622)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:219)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
	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:132)
	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.ElementContainerImpl.setSelectedElementGen(ElementContainerImpl.java:170)
	at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:188)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:651)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:615)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:790)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.bringToTop(PartServiceImpl.java:404)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1239)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3205)
	at org.eclipse.ui.internal.WorkbenchPage.lambda$9(WorkbenchPage.java:3110)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:72)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3108)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3078)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3069)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:570)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:525)
	at org.eclipse.ui.actions.OpenFileAction.openFile(OpenFileAction.java:103)
	at org.eclipse.ui.actions.OpenSystemEditorAction.run(OpenSystemEditorAction.java:96)
	at org.eclipse.ui.actions.RetargetAction.run(RetargetAction.java:215)
	at org.eclipse.ui.navigator.CommonNavigatorManager$1.open(CommonNavigatorManager.java:183)
	at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:48)
	at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:797)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.ui.internal.JFaceUtil.lambda$0(JFaceUtil.java:47)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:174)
	at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:794)
	at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1110)
	at org.eclipse.ui.navigator.CommonViewer.handleOpen(CommonViewer.java:454)
	at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:275)
	at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:270)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:310)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4173)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3986)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3585)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1160)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1049)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:633)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:557)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:660)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:597)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1468)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1441)

Steps to Reproduce

Open create a new .aadl file, put this in it:

package Example

public
  
 thread group threadA
    features
      inputA: in feature group;
      outputA: out feature group;
  end threadA;
  
  thread group implementation threadA.impl
    subcomponents
      t0 : thread;
    annex behavior_specification {**
    states
    s0: initial complete state;
    s1: final state;
    transitions
    s0 -[ on dispatch inputA]-> s1 {outputA:=1};
    **};
  end threadA.impl;

  thread group threadB
    features
      inputB: in feature group;
      outputB: out feature group;
  end threadB;
  
  thread group implementation threadB.impl
    subcomponents
      t0 : thread;
      annex behavior_specification {**
    states
    s0: initial complete state;
    s1: complete state;
    s2: final state;
    transitions
    s0 -[ on dispatch ]-> s1 {outputB:=1};
    s1 -[ on dispatch inputB]->s2;
    **};
  end threadB.impl;

  process processA
    features
      inputA: in feature group;
      outputA: out feature group;
  end processA;
  
  process processB
    features
      outputB: out feature group;
      inputB: in feature group;
  end processB;

  process implementation processA.impl
    subcomponents
      tA: thread group threadA.impl;
    connections
      throughput : feature inputA -> tA.inputA;
      throughput2 : feature tA.outputA -> outputA;
  end processA.impl;
  
  process implementation processB.impl
    subcomponents
      tB: thread group threadB.impl;
    connections
      throughput: feature tB.outputB -> outputB;
      throughput2: feature inputB -> tB.inputB;
  end processB.impl;
  
  processor core
  end core;

  processor implementation core.impl
  end core.impl;

  system Example
  end Example;
  
  system implementation Example.impl
    subcomponents
      core1: processor core.impl;
      partAProcess: process processA.impl;
      partBProcess: process processB.impl;
    connections
      procBToA: feature partBProcess.outputB -> partAProcess.inputA;
      procAToB: feature partAProcess.outputA -> partBProcess.inputB;
  end Example.impl;
  
end Example;

Environment

  • OSATE Version: 2.6.0
  • Operating System: Windows 7
@smithdtyler

This comment has been minimized.

Copy link
Author

@smithdtyler smithdtyler commented Nov 18, 2019

Tagging @Etienne13

@lwrage

This comment has been minimized.

Copy link
Contributor

@lwrage lwrage commented Nov 18, 2019

Does this work in any older OSATE version?

@Etienne13

This comment has been minimized.

Copy link
Contributor

@Etienne13 Etienne13 commented Nov 19, 2019

Hi Tyler,

I will investigate the reasons of the crash, which seems to be a bug. However, I see some incorrect usage of the BA in your AADL example:

  • I don't think feature groups can be used in a dispatch condition.
  • I don't think a dispatch condition can be used in a thread group (given a thread group cannot be associated a dispatch_protocol property).
  • I don't think you can assign a value to an output feature group.

Etienne.

@smithdtyler

This comment has been minimized.

Copy link
Author

@smithdtyler smithdtyler commented Nov 19, 2019

Does this work in any older OSATE version?

In 2.5.2 this file causes recurring xtext pop-up warning dialogs, but the AADL source is displayed.

@lwrage

This comment has been minimized.

Copy link
Contributor

@lwrage lwrage commented Nov 19, 2019

The exception disappears after adding && !resolvedRef.isEmpty() to the condition in the if-statements on lines 574 and 1055 of AadlBaTypeChecker.java.
However, this doesn't seem to be the correct fix because no errors are displayed in the editor even though there should be errors according to Etienne's comment above.

@Etienne13

This comment has been minimized.

Copy link
Contributor

@Etienne13 Etienne13 commented Nov 21, 2019

Should be fixed after integration of PR #2069

@Etienne13 Etienne13 closed this Nov 21, 2019
@lwrage lwrage added this to the 2.6.1 milestone Nov 21, 2019
@lwrage lwrage reopened this Nov 21, 2019
@lwrage

This comment has been minimized.

Copy link
Contributor

@lwrage lwrage commented Nov 21, 2019

merged

@lwrage lwrage closed this Nov 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.