java error
-
Haven't seen this one before.
Error: java.lang.StackOverflowError
java.lang.StackOverflowError
at java.util.Arrays.hashCode(Arrays.java:4146)
at java.util.Objects.hash(Objects.java:128)
at games.strategy.engine.data.DefaultAttachment.hashCode(DefaultAttachment.java:132)
at java.util.HashMap.hash(HashMap.java:339)
at java.util.HashMap.containsKey(HashMap.java:596)
at games.strategy.triplea.attachments.AbstractConditionsAttachment.testAllConditionsRecursive(AbstractConditionsAttachment.java:179)
at games.strategy.triplea.attachments.AbstractConditionsAttachment.testAllConditionsRecursive(AbstractConditionsAttachment.java:180)
at games.strategy.triplea.attachments.AbstractConditionsAttachment.testAllConditionsRecursive(AbstractConditionsAttachment.java:180)
at games.strategy.triplea.attachments.AbstractConditionsAttachment.testAllConditionsRecursive(AbstractConditionsAttachment.java:180)
at games.strategy.triplea.attachments.AbstractConditionsAttachment.testAllConditionsRecursive(AbstractConditionsAttachment.java:180)
at games.strategy.triplea.attachments.AbstractConditionsAttachment.testAllConditionsRecursive(AbstractConditionsAttachment.java:180)
at gamGoogle didn't know what it was. Must be triplea specific. Noticed it says "java 179" the first line and then goes to "180" and just repeats itself a few hundred times.
Checked what I did and couldn't find anything wrong. I'm gonna start over and try again. Just curious if anyone knows what it is : )
Thanks
Did some more searching. Looks like I'm trying to make two things the same. Which is kinda what I'm doing. Anyway, no biggie : )
-
@beelee Usually that means you have an endless loop. Like 1 condition pointing to another condition pointing back to the first condition. I'd need to see that map in order to debug it further.
-
@redrum right on. i went ahead and redid it and got it to work. Just hadn't seen the error before and was curious in case i see it again. Thanks : )
-
@redrum That might be something we could check in the code in general because erroring with a Stackoverflow is really not a good way to tell someone something has been misconfigured.
-
@roiex Agree. Checking and having a better error message would be nice though its the first time I've ever seen it so probably not super common.
-
A StackOverflowError is simply signals that there is no more memory available. It is to the stack what an OutOfMemoryError is to the heap: it simply signals that there is no more memory available. JVM has a given memory allocated for each stack of each thread, and if an attempt to call a method happens to fill this memory, JVM throws an error. Just like it would do if you were trying to write at index N of an array of length N. No memory corruption can happen. The stack can not write into the heap.
The common cause for a stackoverflow is a bad recursive call. Typically, this is caused when your recursive functions doesn't have the correct termination condition, so it ends up calling itself forever. Or when the termination condition is fine, it can be caused by requiring too many recursive calls before fulfilling it.
Here's an example:
public class Overflow { public static final void main(String[] args) { main(args); } }
That function calls itself repeatedly with no termination condition. Consequently, the stack fills up because each call has to push a return address on the stack, but the return addresses are never popped off the stack because the function never returns, it just keeps calling itself. If the stack is full you can't push, if you do you'll get stack overflow error. StackOverflowError is avoidable if recursive calls are bounded to prevent the aggregate total of incomplete in-memory calls (in bytes) from exceeding the stack size (in bytes).