Add-Ons & Services

Poco on Android causing segfaults when exceptions are used.

Please post support and help requests here.

Poco on Android causing segfaults when exceptions are used.

Postby klk » 30 Dec 2012, 05:37

Hi all,

I'm porting a C++ app to Android and am noticing issues with exceptions when I have Poco library linked to my program.

Here's a simple test program I am using to demonstrate this behavior: http://pastebin.com/pQyeYMrg

When I use Android NDK and compile it normally (with the Poco include and exception code commented out), it runs fine. The std::exception is thrown and caught normally. Here is how I compile it:
Code: Select all
./android-toolchain-ndk-r7/bin/arm-linux-androideabi-g++ -Wall -g -O0 -rdynamic -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DANDROID -Xlinker --fix-cortex-a8 -frtti -fexceptions -I./sysroot/usr/include - -L./sysroot/usr/lib test_exceptions.cpp -o test_exceptions -lsupc++ -lgnustl_shared

However, when I uncomment the Poco usage and add -lPocoFoundation, I get a segfault when trying to catch the std::exception (the Poco exception works fine). Here is the backtrace.

Code: Select all
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 3314]
0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
#1  0x40261b30 in __cxa_type_match () from /home/flingo/workbench/android-toolchain-ndk-r7/sysroot/usr/lib/libPocoFoundation.so.11
#2  0x402630c0 in __gxx_personality_v0 () from /home/flingo/workbench/android-toolchain-ndk-r7/sysroot/usr/lib/libPocoFoundation.so.11
#3  0x400b0200 in __gnu_Unwind_RaiseException (ucbp=0xd90b8, entry_vrs=0x411b484c) at /tmp/ndk-digit/src/build/../gcc/gcc-4.4.3/libgcc/../gcc/config/arm/unwind-arm.c:830
#4  0x400b0738 in ___Unwind_RaiseException () at /tmp/ndk-digit/src/build/../gcc/gcc-4.4.3/libgcc/../gcc/config/arm/libunwind.S:334
#5  0x40263414 in __cxa_throw () from /home/flingo/workbench/android-toolchain-ndk-r7/sysroot/usr/lib/libPocoFoundation.so.11
#6  0x00052340 in Flingo::Fingerprint::set_sampling (width=720, height=576) at ../common/fingerprint.cpp:369
#7  0x00092ff4 in CIDClient::client_loop (this=0xbe86c518) at cidclient.cpp:399
#8  0x00095288 in CIDClient::run (this=0xbe86c518) at cidclient.cpp:641
#9  0x4020fe14 in Poco::ThreadImpl::runnableEntry(void*) () from /home/flingo/workbench/android-toolchain-ndk-r7/sysroot/usr/lib/libPocoFoundation.so.11
#10 0x400e1c6c in ?? ()

It looks like Poco's library is handling the exception, by overriding the __cxa_throw function? I'm not sure how to prevent this from occurring :shock: .

Posts: 1
Joined: 29 Dec 2012, 23:36

Re: Poco on Android causing segfaults when exceptions are us

Postby alex » 30 Dec 2012, 18:26

The output you supplied is obviously not from the simple pastebin example. It would be easier to understand what's going on if you posted output from the simple example.
Posts: 1181
Joined: 11 Jul 2006, 16:27
Location: United_States

Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest