ndk5 exception crash with third-party library

by wasabee18 » Thu, 12 May 2011 09:01:05 GMT


Sponsored Links
 i everyone, that's my first post, please be nice :)
My problem is as follows:

I have 2 library, namely lib1 and lib2 compiled with standalone
toolchain.
Both libs need to use stl and exception.
I am using ndkr5, and i have problem with exception !

According to the doc in ndk (document android-ndk-r5b/docs/CPLUSPLUS-
SUPPORT.html), it is mentioned that :
"
WARNING: IMPORTANT CAVEAT

AT THE MOMENT, OUR STLPORT IMPLEMENTATION DOES NOT SUPPORT
EXCEPTIONS
AND RTTI. PLEASE BE SURE TO NOT USE -fexceptions OR -frtti IN ALL
MODULES THAT USE IT.

IF YOU NEED THESE, PLEASE USE "gnustl_static".
"

so in my Application.mk, I have added:
APP_STL := gnustl_static

==================== my test with one single lib (promising)
=================================
I tested as follows:
1) Test 1 :
if i use try/catch within jni, it works with gnustl_static, but it
works as well for stlport_static. i assume it works for stlport_shared
as well
example:
try {
throw 1
} catch (in e) {
LOHI("catch int %d", e); // OK
}

2) Test 2 :
if i use try/catch within my external lib, say in lib1, then it works
with gnustl_static, but it works as well for stlport_static. i assume
it works for stlport_shared as well.
example:
try {
throw 1
} catch (in e) {
LOHI("catch int %d", e); // OK
}

3) Test 3:
if i throw the exception from the external lib and try to catch it
withing the jni code, then the app crashes if i use gnustl_static.
example:
lib.c
void func()
{
throw 1;
}
and in jni:
try{
func(); // CRASH
} catch (int e) {
LOHI("catch int %d", e);
}

I have figured that if i use stlport_static instead of gnustl_static,
then it works! This is contradictory to what documentation says ... ??
Can someone share their experience ?

Anyway, my first tests finished, I have tried with 2 libs instead of a
single one... and the problems started.

=========================== end my test with one single lib
================================


=================my external libs compiled with standalone toolchain
===========================
my 2 external libs are as follows:
lib1 has just one file lib1.c containing one function:
void lib1_func1(int *i)
{
throw 11;
}
According to doc android-ndk-r5b/docs/STANDALONE-TOOLCHAIN.html, it is
mentioned that:
"
The toolchain binaries *do* support C++ exceptions and RTTI by
default.
They are enabled by default, so use -fno-exceptions and -fno-rtti if
you
want to disable them when building sources with them (e.g. to generate
smaller machine code).

NOTE: You will need to explicitely link with libsupc++ if you use
these
features. To do this, use -lsupc++ when linking binaries, as in:

arm-linux-androideabi-g++ .... -lsupc++

"

so i compile and link against lsupc++ as:
arm-linux-androideabi-g++ -mthumb -O2 -g -Wall -fpic -c lib1.c -o
lib1.o
arm-linux-androideabi-g++ -shared -Wl,-soname,liblib1.so lib1.o -lsupc
++ -o liblib1.so

lib2 has just one file lib2.c containing one function:
void lib2_func1(int *i)
{
throw 21;
}
i compile it as (linking against libsupc++):
arm-linux-androideabi-g++ -mthumb -O2 -g -Wall -fpic -c lib2.c -o
lib2.o
arm-linux-androideabi-g++ -shared -Wl,-soname,liblib2.so lib2.o -lsupc
++ -o liblib2.so

=================== end external lib
===================================================

===================== Android.mk



Re: ndk5 exception crash with third-party library

by Marcin Orlowski » Thu, 12 May 2011 17:01:31 GMT


 



I beliee your problem shall be discussed on NDK list, not here (SDK).

Regards,
Marcin Orlowski

*Tray Agenda < http://bit.ly/trayagenda> ;* - keep you daily schedule handy...
*Date In Tray* < http://bit.ly/dateintraypro> ; - current date at glance...
WebnetMobile on *Facebook < http://webnetmobile.com/fb/> ;* and
*Twitter< http://webnetmobile.com/twitter/> ;
*

-- 


Sponsored Links


Re: ndk5 exception crash with third-party library

by wasabee18 » Fri, 20 May 2011 17:24:28 GMT


 sorry. I intended to post it on ndk list. my mistake.
I have re-posted to ndk list.

Thanks.






-- 



Other Threads

1. Mod: Gathering ID-Android With XL, Minggu, 17 Januari 2010 (Soho Music Cafe, Lantai 5 Senayan City)

Hari/Tanggal   :  Minggu, 17 Januari 2010
Waktu             :  13:00 s/d 16:00  WIB
Tempat           : Soho Music Cafe, Lantai 5  Senayan City

Acara bersifat  santai, lebih banyak berdiskusi dan sharing session,
akan disiapkan juga media presentasi (proyektor+layar) untuk acara
presentasi dan sharing session.


Mohon maaf kepada rekan-rekan yang mendaftar, tidak semua bisa kami
layani untuk hadir.

Berikut nama-nama yang sudah mendaftar untuk hadir, jika berhalangan
hadir, mohon segera diberitahu ke email:  agus.hamonan...@gmail.com
agar rekan-rekan yang masuk daftar tunggu bisa hadir.


01.Agus Hamonangan
02.Lucky Sebastian
03.Handono Warih
04.Dolly Surya
05.Rowdy Fath'a
06.Mohammad Jaedi
07.Muhammad Amiral
08.Adi Nooranto
09.Yopie Suryadi
10.Ardhy Wisnu Nugroho
11.Marhendriana
12.Bayu Isvandaryant
13.Jumali Ariefin
14.Bayu Wicaksono
15.Titi Rusdi
16.Oon Arfiandwi
17.Christianus Sandjaja
18.Tri Wahono
19.Adinda Erisyanita
20.Rachmat Gerhantara
21.Fransiskus
22.Adrianto Dimaz
23.G. Arie S. Antara (EsMod)
24.Oktora
25.Pandu
26.Kiki Halimtan
27.Prasetyo Benediktus
28.Jafar Nauli
29.F. Joko Luhur Yuwono
30.Daniel Tumiwa
31.Richard Lizardi
32.Arief WA
33.Pandu Kresnomurti
34.Gunawan
35.Billy
36.Hendra Muliadi
37.Faizal Adiputra
38.Renner Chen
39.Bimo Wicaksono
40.Henry Wiwiet
41.Donald Tang
42.Nareen kameshwara
43.Rifki Adrian
44.Dede Ardian
45.William Setiadi
46.Ronny Iskandar
47.Riswan Christianto
48.Hans Nayoan
49.Eddy Yuniar
50.Ben Hiroshi
51.Ari Pramuditta
52.M.A. Sanjaya
53.Johan 'jojo'
54.Benny Djodjokusumo
55.Reno A
56.Anton Japutra
57.Subanindyo A
58.Bambang Dwi Atmoko
59.Arief Burhanuddin
60.Adhari C Mahendra

2. GMail App Stuck on Sending

You reply to an e-mail in the gmail app, and it says "sending" in red
text forever.

It's annoying as there is no option to "try again" and you can't copy
the reply you just typed out, so you are forced to write it all again.

Anyone else get this problem from time to time?  Any advise?

3. android emulator and AudioRecord - audio in

4. Creating custom button looks?

5. Load image from Jar file

6. ClearTaskOnLaunch flag is not working

7. Scrolling an EditText