Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How do I trace this error..?  (Read 2988 times)
0 Members and 1 Guest are viewing this topic.
Offline Renoria

Junior Member




...


« Posted 2009-04-22 17:20:31 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
        at java.util.ArrayList.add(ArrayList.java:370)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)
        at java.util.SubList.add(AbstractList.java:633)


I keep getting that error.. how do I trace it?
Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2009-04-22 17:32:04 »

The funny thing is, that ONLY with StackOverflowExceptions, the stack is reversed.

I'm pretty sure you're adding a (sub)list in itself.


Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Renoria

Junior Member




...


« Reply #2 - Posted 2009-04-22 17:50:23 »

Any way to debug?  Sad
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2009-04-22 17:55:16 »

As the stacktrace doesn't reveal the source, you can start with scattering System.out.println("something"); through your code, as if it's a binary search for the locxation of the error.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Renoria

Junior Member




...


« Reply #4 - Posted 2009-04-22 17:55:57 »

I just did a search for sublist(..) in my project and found 2 results:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
        msgz.clear();
        for (MessageEntry m : messages) {
            msgz.add(m);
        }
      int l = showMessages;
      if (messages.size() < l) {
         currentMessageScroll = 0;
         l = messages.size() - 1;
      }
      if (l >= messages.size()){
         l = messages.size() - 1;
      }
      if (currentMessageScroll + l > msgz.size()) {
         currentMessageScroll = msgz.size() - l;
      }
        if (msgz.size() > showMessages)
            msgz = msgz.subList(currentMessageScroll,
               currentMessageScroll + l);
      Collections.reverse(msgz);
        g.setColor(new Color(25, 25, 25));


1  
2  
3  
4  
5  
6  
        
        showInfo.add(new ShowInfoEntry(message));
        if (showInfo.size() > 5) {
            int sz = showInfo.size();
            showInfo = showInfo.subList(sz - 5, sz);
        }


any idea?  Huh
Offline Markus_Persson

JGO Wizard


Medals: 14
Projects: 19


Mojang Specifications


« Reply #5 - Posted 2009-04-22 18:49:09 »

The funny thing is, that ONLY with StackOverflowExceptions, the stack is reversed.

What? That's never happened to me.
It should say what caused the error at the bottom of the stacktrace.


Play Minecraft!
Offline Renoria

Junior Member




...


« Reply #6 - Posted 2009-04-22 18:52:13 »

but it doesn't.....

I posted like 1/100 of the stacktrace because it was longer than 1000 characters :|
Offline Markus_Persson

JGO Wizard


Medals: 14
Projects: 19


Mojang Specifications


« Reply #7 - Posted 2009-04-22 19:11:39 »

Whoa, I just tried it, and riven's right.

Not only is it backwards, it cuts off as well so it never lists the root cause.
Holy moly, that's one useless stack trace. Cheesy


[edit:]
No, wait, it isn't backwards. But it does cut off.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
public class Test
{
    private void crash1() {
        crash2();
    }

    private void crash2() {
        crash3();
    }

    private void crash3() {
        crash1();
    }

    private void doCrash() {
        crash1();
    }

    public static void main(String[] args) {
        new Test().doCrash();
    }
}


Produces this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
C:\dev\Test>java -cp bin Test
Exception in thread "main" java.lang.StackOverflowError
        at Test.crash3(Test.java:18)
        at Test.crash2(Test.java:13)
        at Test.crash1(Test.java:8)
        at Test.crash3(Test.java:18)
        at Test.crash2(Test.java:13)
        at Test.crash1(Test.java:8)
        at Test.crash3(Test.java:18)
        at Test.crash2(Test.java:13)
        at Test.crash1(Test.java:8)
[...]
        at Test.crash1(Test.java:8)
        at Test.crash3(Test.java:18)
        at Test.crash2(Test.java:13)
        at Test.crash1(Test.java:8)
        at Test.crash3(Test.java:18)

C:\dev\Test>

Play Minecraft!
Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #8 - Posted 2009-04-22 19:12:19 »

What? That's never happened to me.
It should say what caused the error at the bottom of the stacktrace.


I always (!!) get the source of the problem at the 'top' (visually) of the stacktrace, with a StrackOverflowException

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Markus_Persson

JGO Wizard


Medals: 14
Projects: 19


Mojang Specifications


« Reply #9 - Posted 2009-04-22 19:15:10 »


I always (!!) get the source of the problem at the 'top' (visually) of the stacktrace, with a StrackOverflowException

That seems much more useful than what I'm getting (see my edit in the post above).

Play Minecraft!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #10 - Posted 2009-04-22 19:17:10 »

Now I'm confused... let me try to cook up an example, otherwise I've been fooling myself all along, but then... I don't get StackOverflowExceptions that often.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Markus_Persson

JGO Wizard


Medals: 14
Projects: 19


Mojang Specifications


« Reply #11 - Posted 2009-04-22 19:18:21 »

I get them all the time. Wink
Recursion is not my friend.

The VM i got the above result with:
1  
2  
3  
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode)

Play Minecraft!
Offline Renoria

Junior Member




...


« Reply #12 - Posted 2009-04-22 19:32:21 »

try this:

void killVM() {
 List<Object> list = new ArrayList<Object>();
 while (true) {list.add(new Object());}
}
Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #13 - Posted 2009-04-22 19:44:21 »

It seems that the JVM cuts the stracktrace to 1024 elements.


Further, my assumption was wrong, and I won't bore you with why I made this assumption, it was just that the top traces normally contained all the info I needed, and I expected it at the bottom.

Still I remember very clearly to have StackOverflowErrors with stacktraces with my main method at the TOP, but until I can reproduce, let's assume my mind is playing tricks on me.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Renoria

Junior Member




...


« Reply #14 - Posted 2009-04-22 19:51:08 »

I've just went and profiled my application, should I post the results?
Offline Renoria

Junior Member




...


« Reply #15 - Posted 2009-04-22 20:09:34 »

Hmm my code is here: http://pastebin.com/m54a9151c

I think that line 624-626 was causing it..

because it rapidly calls paint2D over and over when a ConcurrentModificationException occurrs, i'm still in the process of profiling it though XD
Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #16 - Posted 2009-04-22 20:15:22 »

} catch (ConcurrentModificationException ex) {


Never ever catch a ConcurrentModificationException.

When these are thrown, it means there is a serious problem with your code. Fix that bug, don't gracefully handle the errors it throws at you.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Renoria

Junior Member




...


« Reply #17 - Posted 2009-04-22 20:18:42 »

I fixed that ages ago, I made this class when I was n00b at coding o.o
Offline pjt33
« Reply #18 - Posted 2009-04-23 12:48:17 »

I just did a search for sublist(..) in my project and found 2 results:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
        msgz.clear();
        for (MessageEntry m : messages) {
            msgz.add(m);
        }
      int l = showMessages;
      if (messages.size() < l) {
         currentMessageScroll = 0;
         l = messages.size() - 1;
      }
      if (l >= messages.size()){
         l = messages.size() - 1;
      }
      if (currentMessageScroll + l > msgz.size()) {
         currentMessageScroll = msgz.size() - l;
      }
        if (msgz.size() > showMessages)
            msgz = msgz.subList(currentMessageScroll,
               currentMessageScroll + l);
      Collections.reverse(msgz);
        g.setColor(new Color(25, 25, 25));


1  
2  
3  
4  
5  
6  
        
        showInfo.add(new ShowInfoEntry(message));
        if (showInfo.size() > 5) {
            int sz = showInfo.size();
            showInfo = showInfo.subList(sz - 5, sz);
        }


any idea?  Huh
I really don't understand what you're doing with the first one - I know what it looks like, but the reuse looks very messy. Anyway, both of those look like you're eventually going to get sublists of sublists of sublists of ...

Sublists are meant for getting a view on a full list you're keeping. If you aren't doing that then you're better off simply deleting the elements you don't want. If you can't do that but still want to have sublists of sublists of etc. then maybe you should copy the sublists.

Basically you're not giving enough context for me to be confident in recommending a solution, but the code snippets you have posted look very fishy.
Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #19 - Posted 2009-04-23 14:37:37 »

Indeed. Looks you just want to show the most recent entries.

Use a LinkedList for that, calling addLast() and removeFirst()

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Renoria

Junior Member




...


« Reply #20 - Posted 2009-04-23 16:36:52 »

thanks for the tip. changed it to:

1  
2  
3  
4  
5  
6  
        if (showInfo.size() > 5) {
            int sz = showInfo.size();
            for (int i = 0; i < sz-5; i++) {
            showInfo.remove(i);
         }
        }
Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #21 - Posted 2009-04-23 17:01:53 »

That is almost certainly not what you want.


for (int i = 0; i < N; i++) showInfo.remove(i);


this 'unrolls' to:

showInfo.remove(0);
showInfo.remove(1);
showInfo.remove(2);
showInfo.remove(3);
...


Started with: A,B,C,D,E,F,G,H,I
Remove index 0 => B,C,D,E,F,G,H,I
Remove index 1 => B,D,E,F,G,H,I
Remove index 2 => B,D,F,G,H,I
Remove index 3 => B,D,F,H,I



While you want:

for (int i = 0; i < N; i++) showInfo.remove(0);


Started with: A,B,C,D,E,F,G,H,I
Remove index 0 => B,C,D,E,F,G,H,I
Remove index 0 => C,D,E,F,G,H,I
Remove index 0 => D,E,F,G,H,I
Remove index 0 => E,F,G,H,I



Which is why I advised you to use removeFirst()

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (8 views)
2014-07-29 12:53:52

Dwinin (7 views)
2014-07-29 10:59:34

E.R. Fleming (23 views)
2014-07-29 03:07:13

E.R. Fleming (9 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (51 views)
2014-07-17 23:47:54
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!