Android Question thread error on debug

Mrjoey

Active Member
Licensed User
Longtime User
hey im getting this error just in debug mode , in release mode everything is ok
B4X:
LogCat connected to: B4A-Bridge: samsung GT-I9300-351941062524012
--------- beginning of /dev/log/main
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (service1) Create **
** Service (service1) Start **
** Activity (main) Pause, UserClosed = true **
Connected to B4A-Bridge (Wifi)
sending message to waiting queue (CallSubDelayed - UpdateStatus)
Installing file.
PackageAdded: package:b4a.example
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (bs) Create **
** Service (bs) Start **
java.lang.IndexOutOfBoundsException: index 12
    at java.util.concurrent.atomic.AtomicIntegerArray.checkedByteOffset(AtomicIntegerArray.java:36)
    at java.util.concurrent.atomic.AtomicIntegerArray.get(AtomicIntegerArray.java:83)
    at anywheresoftware.b4a.debug.Debug.ShouldStop(Debug.java:233)
    at b4a.example.main._updatespec(main.java:1660)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.agraham.threading.Threading$1.run(Threading.java:216)
    at java.lang.Thread.run(Thread.java:856)
 

eps

Expert
Licensed User
Longtime User
Is there a For Loop somewhere? It looks like you've got an index of 12, but only expecting to go up to 11, remembering that loops start at 0 not 1.

Maybe it's a timing thing, which is why you don't necessarily see it in Release Mode Code, but maybe you're being lucky..?

Any code you can display? Maybe the threads need to be synchronised to ensure that they wait for each other? Or at least where there is a dependency.
 
Upvote 0

Mrjoey

Active Member
Licensed User
Longtime User
Is there a For Loop somewhere? It looks like you've got an index of 12, but only expecting to go up to 11, remembering that loops start at 0 not 1.

Maybe it's a timing thing, which is why you don't necessarily see it in Release Mode Code, but maybe you're being lucky..?

Any code you can display? Maybe the threads need to be synchronised to ensure that they wait for each other? Or at least where there is a dependency.
B4X:
Sub UpdateSpec
Do While (Paused = False)
my loop here.....
for ...
.......
next
Glsv.RequestRender
loop
end sub
im using a for loop to collect data to the opengl verticies , so i commented all the loop just left do while empty and im still getting this error , and my loop starts from 0
do u think that maybe thread.start is called many times? but im just calling it once
 
Upvote 0

eps

Expert
Licensed User
Longtime User
I don't know it's impossible to tell from the small amount of information you've given and the pseudo code posted.. If you want an answer please provide more information in the question.
 
Upvote 0

Mrjoey

Active Member
Licensed User
Longtime User
The legacy debugger cannot handle threads created with the Threading library. Note that in most cases there is no real need to extra threads. What is this thread doing?

Starting from v3.50 the rapid debugger can work with such threads (the events will be delegated to the main thread).
Well the thread is handeling a loop to fill data to the opengl verticies arrays however i disabled the whole loop by commenting it and then i left the "do while" empty , once i started the thread by calling thread.start i got this error
Does indexoutofbound in release mode makes problems in real life? Or it disapears?
I had an idea to make the loop without the thread but the main thread will freezes and maybe trying to put doevents in the loop will fix the freez but i think the loop will be slow so is there anyway to prevent having a loop without the thread library ? Tnx
 
Upvote 0
Top