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.

Stack overflow error

See original GitHub issue

java.lang.StackOverflowError at java.util.ArrayList.iterator(ArrayList.java:814) at org.ahocorasick.interval.IntervalNode.determineMedian(IntervalNode.java:43) at org.ahocorasick.interval.IntervalNode.<init>(IntervalNode.java:17) at org.ahocorasick.interval.IntervalNode.<init>(IntervalNode.java:36) at org.ahocorasick.interval.IntervalNode.<init>(IntervalNode.java:36) at org.ahocorasick.interval.IntervalNode.<init>(IntervalNode.java:36) at org.ahocorasick.interval.IntervalNode.<init>(IntervalNode.java:36)

(chopping of rest for sake of brevity)

Here is what I am doing.

In test setup I am loading a dictionary into a trie and a set of sentences. Then I am passing each one of the sentences in a loop to the trie and after processing two sentences I get the above error.

    for (String sentence : sentences) {
      Collection<Token> tokens = trie.tokenize(sentence);
      for (Token token : tokens) {
        System.out.println("token: " + token);
      }
      System.out.println("\n");
  }

Does the trie need to be reset after processing of a sentence? If so, what is the call?

Thanks.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
xcurrycommented, Feb 15, 2014

I found the problem. It has to do with adding a word of size 0 (“”) as a dictionary. A bug in the dictionary parsing code (, at end of line) caused it to generate words of 0 length which were being added to the trie. Once I removed the additional commas, it worked.

I guess you can test it by doing trie.addKeyword(“”). Maybe throwing an exception or handling that case gracefully by ignoring it would be better.

0reactions
robert-borcommented, Feb 15, 2014

Your desired implementation has been implemented. I pushed a v0.2.2 to Maven Central. It should be availabe in a couple of hours, 24 hours max.

Once more, thanks for spotting the bug!

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is a StackOverflowError? - Stack Overflow
A StackOverflowError is a runtime error in Java. It is thrown when the amount of call stack memory allocated by the JVM is...
Read more >
How to Fix java.lang.StackOverflowError in Java - Rollbar
The java.lang.StackOverflowError is a runtime error which points to serious problems that cannot be caught by an application. The java.lang.
Read more >
StackOverflowError (Java Platform SE 7 ) - Oracle Help Center
Thrown when a stack overflow occurs because an application recurses too deeply. Since: JDK1.0; See Also: Serialized Form ...
Read more >
Stack overflow - Wikipedia
In software, a stack overflow occurs if the call stack pointer exceeds the stack bound. The call stack may consist of a limited...
Read more >
The StackOverflowError in Java - Baeldung
The StackOverflowError can also be thrown when an application is designed to have cyclic relationships between classes. In this situation, the ...
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