Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Premature destruction of object in Android


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
35 replies to this topic

#21 Andreas Jonsson   Moderators   -  Reputation: 3289

Like
0Likes
Like

Posted 07 March 2013 - 09:31 PM

Tomorrow I'll compare the current code with version 2.23.0. It's almost exactly a year between them, but I don't believe the code for native calling conventions on Android has changed that much. Hopefully I'll be able to identify the problem.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Sponsor:

#22 Grimshaw   Members   -  Reputation: 619

Like
0Likes
Like

Posted 08 March 2013 - 05:43 AM

Allright, just notice that in 2.23.0 I did not use native conventions on android! Its the first time now and I never saw it work at all, so nothing to compare to! If you meant for the other bug, then its allright :D


Indie Game Developer - Daeva Theory Studios

 

Twitter - Facebook

 

Next

Terra - rise of mankind

 

Previous

SFML Game Development (Book)


#23 Andreas Jonsson   Moderators   -  Reputation: 3289

Like
0Likes
Like

Posted 08 March 2013 - 07:33 AM

Oh, ok. Then it is going to be difficult.

 

I'll see if I can find the time to install the Android development kit and play around witth this, hopefully there shouldn't be a lot of changes needed, but a lot of tests needs to be made to determine what's wrong. Especially since debugging seems to be so difficult. This will take time, so you'll need to continue with the generic calling conventions for now.

 

The problem is reproducible in the emulator in the Android development kit as well, right? 


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#24 Grimshaw   Members   -  Reputation: 619

Like
0Likes
Like

Posted 08 March 2013 - 07:45 AM

I don't know that as I always use real devices for testing, but the emulator is a true ARM emulator so it is supposed to be "EXACTLY" like a real device..

 

I will stick to the generics, yes. I would like to give you further help and I will if you need, but I am not sure what to do anymore as I dont have any fair logic of assembly and native conventions..

 

I've been trying to debug the crashes with ndk-stack but nothing is reported to me.. its weird..hard to debug..


Indie Game Developer - Daeva Theory Studios

 

Twitter - Facebook

 

Next

Terra - rise of mankind

 

Previous

SFML Game Development (Book)


#25 Andreas Jonsson   Moderators   -  Reputation: 3289

Like
0Likes
Like

Posted 08 March 2013 - 07:54 AM

Can you do a disassembly of that void testP() function you tested with? Or rather, compile the function to assembler code (compiler switch -s, I believe).

 

At least I should be able to see if the assembler code is how AngelScript expects it to be.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#26 bollµ   Members   -  Reputation: 354

Like
0Likes
Like

Posted 08 March 2013 - 08:41 AM

wow, this is the craziest thing I've read about templates in a while. 

 

Also, have you overloaded the << operator so that you can use it with ofstreams?  that's quite handy :D I'll have to do that sometime.

 

could you post all of the compiler and linker setting you're using? I'm a little curious as to why this is happening, and I have my summer vacations in around ten days. I'll try and reproduce this on MSVC 2010.

 

Thanks


a WIP 2d game engine: https://code.google.com/p/modulusengine/

English is not my first language, so do feel free to correct me :)


#27 Grimshaw   Members   -  Reputation: 619

Like
0Likes
Like

Posted 08 March 2013 - 09:30 AM

What do you mean with the << operator? Didn't get the context :o

 

The settings I can post them later, windows and android even :)

 

@Andreas

 

I created a.cpp , containing only testP(){} and compiled it the same way my engine's library is being compiled, outputting to assembly. Here's the result a.s

 

 

 

.arch armv5te
.fpu softvfp
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 26, 2
.eabi_attribute 30, 6
.eabi_attribute 18, 4
.file "a.cpp"
.text
.align 2
.global _Z5testPv
.type _Z5testPv, %function
_Z5testPv:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
bx lr
.size _Z5testPv, .-_Z5testPv
.ident "GCC: (GNU) 4.6 20120106 (prerelease)"
.section .note.GNU-stack,"",%progbits
 

That should be it, right? Here's the compiler options I used: 

 

 

 

arm-linux-androideabi-g++.exe -S -c a.cpp -Wno-psabi -O0 -marm -fno-strict-aliasing -funswitch-loops -finline-limit=100 -fomit-frame-pointer -fno-exceptions -fpic -fstack-protector -frtti -fno-short-enums
 

 

 


Indie Game Developer - Daeva Theory Studios

 

Twitter - Facebook

 

Next

Terra - rise of mankind

 

Previous

SFML Game Development (Book)


#28 Andreas Jonsson   Moderators   -  Reputation: 3289

Like
0Likes
Like

Posted 08 March 2013 - 10:32 AM

The assembly instruction appears to be as expected.

 

The function is called from as_callfunc_arm_gcc.S with an instruction 'blx r4', so the correct way to return to the caller is with a call to 'bx lr'. 

 

I suspect the crash is likely happening even before the call to the registered function. Probably somewhere in as_callfunc_arm_gcc.cpp.

 

Would you mind adding a few cout's in the as_callfunc_arm.gcc.cpp code to see how far it gets before it crashes? And to see which path it takes in the conditions?


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#29 quarnster   Members   -  Reputation: 266

Like
0Likes
Like

Posted 08 March 2013 - 12:42 PM

About the ARM now, here is the compilation command of one source file from angelscript, compiling the ARM version for the NDK.

"Compile++ thumb : angelscript &lt;= as_scriptengine.cpp
...-mthumb...

Others have touched the code since I first contributed the initial native arm call conventions so this might have changed, but they were originally not designed for interoperating with thumb mode. Your problem might be as easy as making the ndk compile your code in arm mode unless you absolutely need thumb. Just put this in your Android.mk:

LOCAL_ARM_MODE := arm


#30 Grimshaw   Members   -  Reputation: 619

Like
0Likes
Like

Posted 08 March 2013 - 01:37 PM

@quarnster: I added that line to the makefile and it compiled the arm library fine, i tested it and it worked. funny.. :) Thanks.

 

Because im curious, and to make sure that line was the actual fixer, i took it off again and recompiled but i got the same working result.. Could it change the default compiler settings somehow or what?

 

This topic's issues are nice, very nice. :)


Indie Game Developer - Daeva Theory Studios

 

Twitter - Facebook

 

Next

Terra - rise of mankind

 

Previous

SFML Game Development (Book)


#31 Andreas Jonsson   Moderators   -  Reputation: 3289

Like
0Likes
Like

Posted 08 March 2013 - 02:53 PM

@quarnster: Thanks a lot. I would probably not have found that one, at least not anytime soon. Does it matter where in the Android.mk file this line is added? Can I just add it at the end of the file?


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#32 Grimshaw   Members   -  Reputation: 619

Like
0Likes
Like

Posted 08 March 2013 - 03:51 PM

Im still finding it hard to believe this is working hehe, it all seems so tricky.. :)

 

Thanks to you too for the help given!!


Indie Game Developer - Daeva Theory Studios

 

Twitter - Facebook

 

Next

Terra - rise of mankind

 

Previous

SFML Game Development (Book)


#33 Andreas Jonsson   Moderators   -  Reputation: 3289

Like
0Likes
Like

Posted 08 March 2013 - 06:07 PM

I've checked in the change to the Android make file in revision 1588.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#34 quarnster   Members   -  Reputation: 266

Like
0Likes
Like

Posted 09 March 2013 - 12:23 AM


@quarnster: Thanks a lot. I would probably not have found that one, at least not anytime soon. Does it matter where in the Android.mk file this line is added? Can I just add it at the end of the file?


It needs to be between the two include directives.

#35 Andreas Jonsson   Moderators   -  Reputation: 3289

Like
0Likes
Like

Posted 09 March 2013 - 04:47 PM

Thanks. I've updated the file accordingly.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#36 AgentC   Members   -  Reputation: 1284

Like
0Likes
Like

Posted 12 March 2013 - 02:04 AM

I got hit by this bug as well (manifested as a crash when running scripts on Android) but it did not appear before updating the Android NDK to the latest, which suggests the compiler's handling of arm/thumb interoperation has changed.


Every time you add a boolean member variable, God kills a kitten. Every time you create a Manager class, God kills a kitten. Every time you create a Singleton...

Urho3D (engine)  Hessian (C64 game project)





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS