question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

StackOverflowError on each startup, when indexing Javascript

See original GitHub issue

Apache NetBeans version

Apache NetBeans 12.6

What happened

After upgrading NetBeans from 12.0 to 12.6 (and importing the settings from 12.0, as suggested by the UI), I have a StackOverflow error on each startup.

During the “background scanning of projects”, an exception is thrown, and displayed by NetBeans with an infinite loop on org.netbeans.modules.javascript2.editor.index.JsIndexer.storeObject(JsIndexer.java:229) (see stacktrace)

The background scanning of projects never ends, and consumes a lot of CPU in the background

How to reproduce

On my computer, it can be reproduced on each startup.

As a workaround, I could switch to another project group (with other non-javascript projects), then restart Netbeans. In this case, there is no exception and no background CPU usage on startup. But the symptom comes back if I switch back to the project group where I have a specific javascript project.

This project is an open-source one: https://github.com/kiwix/kiwix-js But this project is also open in a project group of another computer with no problem (same OS, same version of Netbeans, also upgraded from 12.0).

Did this work correctly in an earlier version?

Apache NetBeans 12.3 or earlier

Operating System

Ubuntu 20.04.3 amd64, with all updates installed

JDK

OpenJDK 11.0.13 (provided by Ubuntu). Same result with OpenJDK 17.0.1 (provided by Ubuntu)

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

Stacktrace:

java.lang.StackOverflowError
    at java.base/java.util.WeakHashMap.getTable(WeakHashMap.java:350)
    at java.base/java.util.WeakHashMap.get(WeakHashMap.java:398)
    at org.openide.util.lookup.MetaInfServicesLookup.beforeLookup(MetaInfServicesLookup.java:121)
    at org.openide.util.lookup.AbstractLookup.lookupItem(AbstractLookup.java:402)
    at org.openide.util.lookup.AbstractLookup.lookup(AbstractLookup.java:396)
    at org.openide.util.lookup.ProxyLookup.lookup(ProxyLookup.java:281)
    at org.netbeans.modules.javascript2.model.JsElementImpl.isInternalFile(JsElementImpl.java:194)
    at org.netbeans.modules.javascript2.model.JsElementImpl.isPlatform(JsElementImpl.java:188)
    at org.netbeans.modules.javascript2.model.api.IndexedElement$Flag.getFlag(IndexedElement.java:387)
    at org.netbeans.modules.javascript2.editor.index.JsIndexer.createDocument(JsIndexer.java:121)
    at org.netbeans.modules.javascript2.editor.index.JsIndexer.storeObject(JsIndexer.java:221)
    at org.netbeans.modules.javascript2.editor.index.JsIndexer.storeObject(JsIndexer.java:229)
    at org.netbeans.modules.javascript2.editor.index.JsIndexer.storeObject(JsIndexer.java:229)
    at org.netbeans.modules.javascript2.editor.index.JsIndexer.storeObject(JsIndexer.java:229)

(this last line is repeated around 1000 times)

Removing the cache and restarting Netbeans does not help. I’d be happy to help to test/investigate on that issue.

(originally reported on https://issues.apache.org/jira/browse/NETBEANS-6467)

Are you willing to submit a pull request?

No response

Code of Conduct

Yes

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
matthiasblaesingcommented, Feb 27, 2022

Putting the discussion about the indexer in general aside the issue here is that the indexer does not handle self referential structures well. A minimal reproducer is this:

function mod(actions) {
    return actions.map((action) => {
        action = { action };
        return action;
    });
};

With that at least the occurrences finder:

java.lang.StackOverflowError
	at org.netbeans.modules.javascript2.editor.navigation.OccurrencesSupport.findOccurrence(OccurrencesSupport.java:59)
	at org.netbeans.modules.javascript2.editor.navigation.OccurrencesSupport.findOccurrence(OccurrencesSupport.java:80)
	at org.netbeans.modules.javascript2.editor.navigation.OccurrencesSupport.findOccurrence(OccurrencesSupport.java:80)
	at org.netbeans.modules.javascript2.editor.navigation.OccurrencesSupport.findOccurrence(OccurrencesSupport.java:80)

and the indexer are affected:

java.lang.StackOverflowError
	at java.base/java.util.WeakHashMap.get(WeakHashMap.java:398)
	at org.openide.util.lookup.InheritanceTree.searchInterface(InheritanceTree.java:846)
	at org.openide.util.lookup.InheritanceTree.lookup(InheritanceTree.java:215)
	at org.openide.util.lookup.DelegatingStorage.lookup(DelegatingStorage.java:149)
	at org.openide.util.lookup.AbstractLookup.lookupItem(AbstractLookup.java:411)
	at org.openide.util.lookup.AbstractLookup.lookup(AbstractLookup.java:396)
	at org.openide.util.lookup.ProxyLookup.lookup(ProxyLookup.java:281)
	at org.netbeans.modules.javascript2.model.JsElementImpl.isInternalFile(JsElementImpl.java:194)
	at org.netbeans.modules.javascript2.model.JsElementImpl.isPlatform(JsElementImpl.java:188)
	at org.netbeans.modules.javascript2.model.api.IndexedElement$Flag.getFlag(IndexedElement.java:387)
	at org.netbeans.modules.javascript2.editor.index.JsIndexer.createDocument(JsIndexer.java:122)
	at org.netbeans.modules.javascript2.editor.index.JsIndexer.storeObject(JsIndexer.java:222)
	at org.netbeans.modules.javascript2.editor.index.JsIndexer.storeObject(JsIndexer.java:230)
	at org.netbeans.modules.javascript2.editor.index.JsIndexer.storeObject(JsIndexer.java:230)
	at org.netbeans.modules.javascript2.editor.index.JsIndexer.storeObject(JsIndexer.java:230)

the immediate idea is using a Map/Set to store the visited maps would fix this, but that breaks intentional usages.

Here is the original offender (name of the property and the indexable being indexed):

X1: nm$_constant.exports.formatArgs.constantformatArgs#=>#8.action.action.action (node_modules/webdriverio/build/commands/constant.js)
X1: nm$_constant.exports.formatArgs.constantformatArgs#=>#8.action.action.action.action (node_modules/webdriverio/build/commands/constant.js)
X1: nm$_constant.exports.formatArgs.constantformatArgs#=>#8.action.action.action.action.action (node_modules/webdriverio/build/commands/constant.js)
X1: nm$_constant.exports.formatArgs.constantformatArgs#=>#8.action.action.action.action.action.action (node_modules/webdriverio/build/commands/constant.js)
X1: nm$_constant.exports.formatArgs.constantformatArgs#=>#8.action.action.action.action.action.action.action (node_modules/webdriverio/build/commands/constant.js)
X1: nm$_constant.exports.formatArgs.constantformatArgs#=>#8.action.action.action.action.action.action.action.action (node_modules/webdriverio/build/commands/constant.js)
0reactions
mossroycommented, Mar 6, 2022

Thanks, the AssertionError disappears with the config you mentioned.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript with index error - Stack Overflow
The first time this runs, the image is green. It then sets the image to gyr[0], the green image, then index is incremented....
Read more >
KB-1476 StackOverflowError thrown during WebLogic startup
Cause. StackOverflow errors are usually caused by unterminated recursion, where the same errors are being repeated over and over again. This can also...
Read more >
[BUG] StackOverflow crash - large regex produced by ... - GitHub
Describe the bug It seems to possible to crash Opensearch nodes by providing a very large string when attempting to filter on a...
Read more >
What a very bad day at work taught me about building Stack ...
Hi, my name is Sara Chipps, first time Stack blogger, long time Stacker (I've always wanted to say that!). I'm the new Director...
Read more >
How to solve java.lang.StackOverflowError
The java.lang.stackoverflowerror in Java is thrown to indicate that the application's stack was exhausted, due to deep recursion.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found