Forum Xamarin.Android

When throwing exception in native C++ code application crashes.

wakeupwakeup Member ✭✭
edited February 15 in Xamarin.Android

As an example I have a very simple app.
C++ Android Solution created in Visual Studio via File->New->Project->Native-Activity Application (Android).
I am building it and testing with following configuration and devices:
x64, testing on Android 9.0 x86_x64 emulator
ARM32, testing on Samsung Exynos 7884 running Android 9 32bit OS.
Currently using API25, NDK21.

Originally application goes thru green gradient on the device screen.
I have modified application by adding try-catch statement in the main function. In the try section I am throwing an exception.
C++ project part of the solution has been modified to enable exception handling: Properties->C/C++->Code Generation, Enable C++ Exceptions ->Yes (-fexceptions).
Appilcation is crashing as soon as "throw" statement is reached.

I do have an old project code base that is being migrated to the Android.
Exceptions handling is integral part of this code and getting rid of it would be a real hurdle.
It is working, but as soon as "throw" is being reached application is crashing with SEGFAULT/SIGABORT.

There is an article that describes problems with Unwinding.
I have tried to --exclude-libs so far but it does not help.

Sign In or Register to comment.