Followers 0

# Premature destruction of object in Android

## 35 posts in this topic

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

0

##### Share on other sites

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
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


0

##### Share on other sites

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?

0

##### Share on other sites

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
0

##### Share on other sites

@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. :)

0

##### Share on other sites

@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?

0

##### Share on other sites

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

Thanks to you too for the help given!!

0

##### Share on other sites

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

0

##### Share on other sites

@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.
0

##### Share on other sites

Thanks. I've updated the file accordingly.

0

##### Share on other sites

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.

0

## Create an account

Register a new account