SORTARRAY & ADDRESSOF strange issues (suddently).

Previous topic - Next topic

spacefractal

Karma Miwa is suddeent crash, while im have absolute no idea what happens (*** Unhandled exception ***   EXCEPTION_ACCESS_VIOLATION).

Im thinks ADDRESSOF is not working and pointing currectly on the object used.

This can been the various crash issues seen with strings recently which could have been somewhere same thing?

The platform is Windows and can no longer sort object correct.

The crash was accour when im called on this:

SORTARRAY Objectdata[], ADDRESSOF(compared)

and the compared function was this:

Code (glbasic) Select

FUNCTION compared%: a AS Object, b AS Object
   IF a.obid<b.obid THEN RETURN -1
   IF a.obid>b.obid THEN RETURN 1
   RETURN 0
ENDFUNCTION


This have allways worked, but is out of the blue crashing now.

Also the issue can also been in AS as well which use wrong kind of pointer?
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spacefractal

The first object seen not got a correct pointer, while the second object is. Its even more strange. im got this output when im print this code out:

Code (glbasic) Select

FUNCTION compared%: a AS Object, b AS Object
DEPRINT(1)
DEPRINT("1: "+a.obid)
DEPRINT("2: "+b.obid)
    IF a.obid<b.obid THEN RETURN -1
DEPRINT(2)
    IF a.obid>b.obid THEN RETURN 1
DEPRINT(3)
    RETURN 0
ENDFUNCTION


im got this on the last lines (im remove some of it later to avoid a long post):

Code (glbasic) Select

[GLB]->1: 10000 2: 5012
[GLB]->1: 10001 2: 5012
[GLB]->1: 10002 2: 5012
[GLB]->1: 10003 2: 5012
[GLB]->1: 5004 2: 5012
[GLB]->1: 10005 2: 5012
[GLB]->1: 10006 2: 5012
[GLB]->1: 10007 2: 5012
[GLB]->1: 5008 2: 5012
[GLB]->1: 10009 2: 5012
[GLB]->1: 100000 2: 5012
[GLB]->1: 10011 2: 5012
[GLB]->1: 5012 2: 5012
[GLB]->1: 0 2: 5012
[GLB]->1: -1414812757 2: 5012
[GLB]->1: -17891602 2: 5012
[GLB]->1: -1163005939 2: 5012
[GLB]->1: 1 2: 5012
[GLB]->1: -1163005939 2: 5012
[GLB]->1: 6422636 2: 5012
[GLB]->1: 6619213 2: 5012
[GLB]->1: -1442840448 2: 5012
[GLB]->1: 470621898 2: 5012
[GLB]->1: -17891602 2: 5012
[GLB]->1: 969964674 2: 5012
[GLB]->1: -1442840448 2: 5012
[GLB]->1: 470621898 2: 5012
[GLB]->1: -1163005952 2: 5012
[GLB]->1: -1 2: 5012
[GLB]->1: 470621895 2: 5012
[GLB]->1: -1414812757 2: 5012
[GLB]->1: 0 2: 5012
[GLB]->1: 42291344 2: 5012
[GLB]->1: -17891602 2: 5012


So the second pointer works as excepted, but the first pointer goes out of sync and then sooner or later crash out (here im used INTEGER using % to make sure).

The bug is property in glb.h


Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spacefractal

#2
im give up and need to use alternative to SORTARRAY. Im also scaring its the same issue as this one (im newer could fix, sorry):
http://www.glbasic.com/forum/index.php?topic=10605.0

There is some strings on  some objects. The most suddently is when im trying to output the name, then soon its hit 0, then its simply just stop, and newer go anymore future, but you can still escape out. Very strange.

Im take a backup of the currect source code of the game, so can finally fix that string issue (which im guess its iss), its totally strange the first pointer can go out of sync (should not been 0 at all).

Its when im move and testing it on Mac. Im have no idea where its crash and why, but its goes out of sync.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrTAToad

The compare function must NOT be an integer - for some reason it will crash if it is...

spacefractal

#4
im tried both, integer and float (Edit: only on I'd, not function it'd self, testing later6. Same issues with the first pointer.

Its look like its can bee some issue when a string in object have been changed from the standard, and then len of the object can then been wrong.

But it'd funny the second pointer is still correct, but not the first one. Should not output either 0 or very high number. It'd also look it's is a 64bit pointer and not 32bit pointer. 64bit pointers should only uses on 64bit compilers. Other wise it's can return wrong.

It's could also been a totally different issue and not directly on command it's self. Etc when string and dim is used. I'm have just newer seen this behavior before.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

bigsofty

Any chance of a small, compilable, example of the bug, I can't reproduce it at my end?
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

spacefractal

It's more complicated than excepted hoping can replica it on Mac later.

Currently I'm did a workaround using a separated integer only array instead and sorting that, which works fine. The sorted list is only require for painting in correct order anyway.

I'm thinks and pretty sure it's can been the same issues about strings not released correctly and facing it'd could been that issue I'm linked before.

I'm checking later.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrTAToad

Have you tried the example in the help file too?

spacefractal

#8
Not yet. It's a bigger issue than excepted. The debugger is not that help. Hoping later seen its happens on Mac, which have a much better debugger.

Also suddent in some levels, the main sprites was a coin, which im was forced get get the image again to make sure its diddent change. This was also a string. So im not sure its a bug in those commands its self, but more a string issue? Its pretty wierd.

So this is something that property cant been fixed right now.

What im might have seen could been the similar issue as this one (where im thinks the string object is not released correctly):
http://www.glbasic.com/forum/index.php?topic=10605.0
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrTAToad

Its certainly possible, of course - the easiest way would be to try and remove as much code as possible until it works correctly...

spacefractal

I thinks it's the same issue. It's was behavior really strange and was needed to refind the images again, which got lost in the object somehow.

It's was a string. I'm work around it by doing a multi pass for each in the priority it's should draw the sprites.

I'm do sure im take a look later one.

But it's was strange the first pointer was wrong, nut not the second one....

But not a big property, just to mention it.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/