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

Fix unhandled event loop exception when binary parser is not in plugin.xml #137

Merged
merged 1 commit into from
Nov 4, 2022

Conversation

jonahgraham
Copy link
Member

If a .cproject references a binary parser ID that is not in the plug-in XML, or in the XML, but marked as private, the UI cannot display the binary parsers and was raising an ArrayIndexOutOfBoundsException as below.

This fix rewrites the array handling using collections.

!ENTRY org.eclipse.ui 4 0 2022-11-04 09:44:27.409
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.ArrayIndexOutOfBoundsException: Index 7 out of bounds for length 7
	at org.eclipse.cdt.ui.newui.BinaryParsTab.updateData(BinaryParsTab.java:253)
	at org.eclipse.cdt.ui.newui.AbstractCPropertyTab.setVisible(AbstractCPropertyTab.java:253)
	at org.eclipse.cdt.ui.newui.BinaryParsTab.setVisible(BinaryParsTab.java:221)
	at org.eclipse.cdt.ui.newui.AbstractCPropertyTab.handleTabEvent(AbstractCPropertyTab.java:630)
	at org.eclipse.cdt.ui.newui.AbstractPage.updateSelectedTab(AbstractPage.java:412)
	at org.eclipse.cdt.ui.newui.AbstractPage$4.widgetSelected(AbstractPage.java:382)

This is needed more-so now so that the changes proposed in #135 doesn't cause the above exception if a project references the old ID.

Steps to reproduce the bug:

  1. Create a project without Remove deprecated binary parsers and supporting code #135 merged
  2. In Project Build Settings, check some of the deprecated binary parsers:

image

  1. Open the above project with Remove deprecated binary parsers and supporting code #135 merged and open the binary parsers page
  2. Observe the above mentioned exception in the log and the binary parser list is empty:

image

The same could be observed by opening a project created with some third-party plug-in that defines such a binary parser and then opening that project without the third-party plug-in installed.

…n.xml

If a .cproject references a binary parser ID that is not in
the plug-in XML, or in the XML, but marked as private, the
UI cannot display the binary parsers and was raising an
ArrayIndexOutOfBoundsException as below.

This fix rewrites the array handling using collections.


```java
!ENTRY org.eclipse.ui 4 0 2022-11-04 09:44:27.409
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.ArrayIndexOutOfBoundsException: Index 7 out of bounds for length 7
	at org.eclipse.cdt.ui.newui.BinaryParsTab.updateData(BinaryParsTab.java:253)
	at org.eclipse.cdt.ui.newui.AbstractCPropertyTab.setVisible(AbstractCPropertyTab.java:253)
	at org.eclipse.cdt.ui.newui.BinaryParsTab.setVisible(BinaryParsTab.java:221)
	at org.eclipse.cdt.ui.newui.AbstractCPropertyTab.handleTabEvent(AbstractCPropertyTab.java:630)
	at org.eclipse.cdt.ui.newui.AbstractPage.updateSelectedTab(AbstractPage.java:412)
	at org.eclipse.cdt.ui.newui.AbstractPage$4.widgetSelected(AbstractPage.java:382)
```
} else { // project
ICConfigurationDescription[] cfgs = page.getCfgsEditable();
ids = CoreModelUtil.getBinaryParserIds(cfgs);
}
Object[] data = new Object[configMap.size()];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key error is that size of data was wrong, it assumed that it needed to be the size of all plugin.xml defined binary parsers. It didn't account for ids having other ids, so the i variable below would be over incremented.

All this is solved by removing hard coded array sizes.

Copy link
Member

@ruspl-afed ruspl-afed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions
Copy link

github-actions bot commented Nov 4, 2022

Test Results

     602 files       602 suites   19m 24s ⏱️
10 183 tests 10 162 ✔️ 21 💤 0
10 146 runs  10 125 ✔️ 21 💤 0

Results for commit a781349.

@jonahgraham jonahgraham merged commit ac979bd into eclipse-cdt:main Nov 4, 2022
@jonahgraham jonahgraham deleted the fix_unhandled_exception branch November 4, 2022 16:02
@jonahgraham
Copy link
Member Author

Thanks for the review @ruspl-afed

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.

2 participants