Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (604)
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  
  Impossible ArrayIndexOutOfBoundsException  (Read 1834 times)
0 Members and 1 Guest are viewing this topic.
Offline ryanm

Senior Devvie


Projects: 1
Exp: 15 years


Used to be bleb


« Posted 2011-01-14 16:39:00 »

Can anyone see how this frustum code can cause the following exception?
1  
2  
3  
java.lang.ArrayIndexOutOfBoundsException
at com.ryanm.droid.rugl.util.geom.Frustum.extractFromOGL(Frustum.java:180)
...


The offending line 180:
1  
frustum[ 3 ][ 0 ] /= t;

The declaration of the frustum arrays:
1  
private final float[][] frustum = new float[ 6 ][ 4 ];

The only instances of "new" in that file are the 4 at the start, so there's no way that the arrays are being changed after construction.
To put it mildly:  Huh

I've had 5 reports of this from 3 different users. The only possible explanation that I can see someone out there has taken my (freely available) code, b0rked it, and is distributing broken apks.

Does anyone have an alternative?
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 841
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2011-01-14 16:49:56 »

I expect those users are running an older version of your application, and there is totally different code on their line 180.

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

JGO Coder


Medals: 17



« Reply #2 - Posted 2011-01-14 17:04:21 »

I agree with Riven.  If there truly was an exception then line 179 should throw it first.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline SimonH
« Reply #3 - Posted 2011-01-14 17:05:22 »

Also strange it doesn't throw at line 172 first (which has the same indices);
1  
frustum[ 3 ][ 0 ] = clip[ 3 ] - clip[ 1 ];

I suspect Riven's right & your user's code is different from yours. Either get them to send you their code & disassemble it or make sure they have your latest.

People make games and games make people
Offline ryanm

Senior Devvie


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #4 - Posted 2011-01-14 17:35:24 »

I wish it were that easy. The code was lifted straight from somewhere else, java-fied and committed.  I haven't touched it since, so I don't think there are any other versions of this class out there (at least from me). Also, the crash report was versioned :-/
Offline Abuse

JGO Knight


Medals: 15


falling into the abyss of reality


« Reply #5 - Posted 2011-01-14 18:17:57 »

The only other possibility I can think of is that the compiler you used to build the classes put in a borked line number table.
Though I've only ever come across this when dealing with classes that have had some kind of bytecode transformation applied to them.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline princec

« JGO Spiffy Duke »


Medals: 434
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #6 - Posted 2011-01-14 18:18:39 »

private final float[][] frustum = new float[ 6 ][ 4 ];

What's to stop one of the float[] arrays in the float[6] array being altered? So basically, not as impossible as it looks.
(Also, call me a n00b, but I didn't even know you could declare multidimensional arrays fully instantiated like that in Java.)

Cas Smiley

Offline DzzD
« Reply #7 - Posted 2011-01-14 18:57:51 »

(Also, call me a n00b, but I didn't even know you could declare multidimensional arrays fully instantiated like that in Java.)
Cas Smiley
you really ?!  Smiley it is native value they dont need to be instanciated (instanciating them would look strange tab[n][m]=new float ? , you must be tired
EDIT:
!!!
or I must be tired !

tab[n]=new float[m]

sorry...

Offline DzzD
« Reply #8 - Posted 2011-01-14 19:03:50 »

@OP:

ok, probably :

probleme come from the way java manage array with two dimension, in C/C++ they are managed as a  continous memory  area allocated at once, while in java it is one array (1D) , with each entry pointing to another location, this enable to use multidimensional array with different lenght at each entry for the second dimension : in java double dimension array can be NOT rectangular

what you should do is :
1  
2  
for (int n=0;n<4;n++)
 tab[n]=new float[6];


sorry ... I never use multidimensional array in java

EDIT:
It is usually more easy to use 1D (IMO), work as in C and I found them easier (and faster too) :
1  
2  
float tab[]=new float[4*6];
tab[x+y*4]=...

Offline avm1979
« Reply #9 - Posted 2011-01-14 19:08:27 »

(Also, call me a n00b, but I didn't even know you could declare multidimensional arrays fully instantiated like that in Java.)

Hah, I just figured that out a few days ago.  My reaction: o_O, followed by embarrassment.

On-topic - I don't see *anywhere* in this class that could throw that exception.  And since the arrays are private, it's unlikely outside code is changing them.  I hate to even suggest this, but maybe you've hit a bug in the VM?  Seems like it's either that, a problem with the class files, or we're all missing something patently obvious.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline DzzD
« Reply #10 - Posted 2011-01-14 19:12:42 »

this one ?
1  
frustum[ 3 ]=new float[0] 


or rather try this :

1  
2  
3  
float f[][]=new float[6][4];
f[0]=new float[0];
f[0][0]=3;


output :
Quote
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0

Offline avm1979
« Reply #11 - Posted 2011-01-14 19:14:00 »

this one ?
1  
frustum[ 3 ]=new float[0] 


Huh?  Not seeing that anywhere in the code.

Offline DzzD
« Reply #12 - Posted 2011-01-14 19:17:23 »

something strange is that you dont get the indice in the exception

Quote
java.lang.ArrayIndexOutOfBoundsException

Offline teletubo
« League of Dukes »

JGO Ninja


Medals: 48
Projects: 4
Exp: 8 years



« Reply #13 - Posted 2011-01-14 19:22:56 »

Really creppy , even because in the previous line you access successfully this position

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
 >>>>>      frustum[ 3 ][ 0 ] = clip[ 3 ] - clip[ 1 ];    
                frustum[ 3 ][ 1 ] = clip[ 7 ] - clip[ 5 ];
                frustum[ 3 ][ 2 ] = clip[ 11 ] - clip[ 9 ];
                frustum[ 3 ][ 3 ] = clip[ 15 ] - clip[ 13 ];
               
                /* Normalize the result */


                t =
                                sqrt(  >>>>>frustum[ 3 ][ 0 ]<<<<<<<< * frustum[ 3 ][ 0 ] + frustum[ 3 ][ 1 ]      
                                                * frustum[ 3 ][ 1 ] + frustum[ 3 ][ 2 ] * frustum[ 3 ][ 2 ] );
               
              frustum[ 3 ][ 0 ] /= t;


 Definately something has changed or the exception would be thrown on the previous lines

Offline ryanm

Senior Devvie


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #14 - Posted 2011-01-18 10:26:13 »

Thanks for the feedback: So it seems that this is at least not embarrassingly obviously my fault. The possibilities that I can see:
  • Malicious users: they've altered or fabricated the error reports. I've had reports from 3 different people, I'd hope that they'd have more to do with their lives than conspire to troll me with bizarre error reports.
  • Some error in the reporting mechanism. I can't see it if it's there. Anyone else?
  • VM error. I've encountered some worrying stuff in android before, but this is on a different level entirely...

I suppose the android mailing list would be the next step...
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.

rwatson462 (36 views)
2014-12-15 09:26:44

Mr.CodeIt (27 views)
2014-12-14 19:50:38

BurntPizza (61 views)
2014-12-09 22:41:13

BurntPizza (96 views)
2014-12-08 04:46:31

JscottyBieshaar (56 views)
2014-12-05 12:39:02

SHC (72 views)
2014-12-03 16:27:13

CopyableCougar4 (74 views)
2014-11-29 21:32:03

toopeicgaming1999 (134 views)
2014-11-26 15:22:04

toopeicgaming1999 (125 views)
2014-11-26 15:20:36

toopeicgaming1999 (35 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!