Azure SpatialAnchors AppProperties crash in Android NDK - android

Azure SpatialAnchors NDK crashes on inserting/looking up AppProperties.
After unsuccessful attempts to fix it in my custom app I added the code to the official Microsoft tutorial which builds and works fine.
https://github.com/Azure/azure-spatial-anchors-samples/blob/master/Android/NDK/app/src/main/cpp/AzureSpatialAnchorsApplication.cpp#L570
visual.cloudAnchor = std::make_shared<CloudSpatialAnchor>();
visual.cloudAnchor->LocalAnchor(visual.localAnchor);
std::shared_ptr<IMap<std::string, std::string>> properties = visual.cloudAnchor->AppProperties(); // new code
// verified properties is not null
properties->Insert(R"(model-type)", R"(frame)"); // crash!
ERROR: A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 22056
Here is the documentation which shows how to set app properties https://learn.microsoft.com/en-us/azure/spatial-anchors/how-tos/create-locate-anchors-cpp-ndk

Thank you for reaching out!
This is a duplicate of this GitHub issue
The team will follow up there

Related

How to find reason for MAUI app failure on Android ([libc] Fatal signal 11 (SIGSEGV))?

I am trying to explore .NET 6 with MAUI preview 14 to run code on Windows, Android and other platforms.
While my code works fine on Windows, on Android, where I run my code using VS 2022 17.2 Preview 2 in a Pixel 5 emulator with x86_64 architecture, any attempt to instantiate the central instance of the Processor class (with e.g. var processor = new Processor(true); of a library named SaxonCS (https://www.nuget.org/packages/SaxonCS/) I use crashes the application with an error [libc] Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)
Loaded assembly: /data/data/com.companyname.mauiapp4sax1121test2/files/.__override__/Singulink.Numerics.BigDecimal.dll [External]
Loaded assembly: /data/data/com.companyname.mauiapp4sax1121test2/files/.__override__/Singulink.Numerics.BigIntegerExtensions.dll [External]
[libc] Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x10 in tid 14860 (pp4sax1121test2), pid 14860 (pp4sax1121test2)
What does that error mean, how to find out in more detail what causes it and how to avoid it?
As for the logs, they don't seem to show more info, at least to me as the error doesn't seem to be more detailed:
Uhrzeit Gerätename Typ PID Tag Meldung
03-22 11:15:53.714 pixel_5_-_api_30 Error 14953 DEBUG signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x10
03-22 11:15:53.633 pixel_5_-_api_30 Error 14860 libc Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x10 in tid 14860 (pp4sax1121test2), pid 14860 (pp4sax1121test2)
I filed this issue as a potential bug on MAUI in https://github.com/dotnet/maui/issues/6811.
#lambdageek from Microsoft was able to identify the bug https://github.com/dotnet/runtime/issues/76312 in the Mono runtime that caused this crash, his fix is now in the November 2022 6.0 .NET service update and in .NET 7.0 GA so using these up to date versions of .NET and MAUI under Android SaxonCS does no longer crash.

Visual Studio 2019 - Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x7a7bff4000 in tid 12503 (Thread Pool Wor), pid 11057

I have been stuck with Fatal Signal errors since using Visual Studio 2019 or 2022 to compile my Xamarin Android Project for more than 3 weeks.
I have used ndk-stack and other tools to see any meaningful stack trace I have failed and our project is not going ahead because of this.
Please note that the same exact code base works perfectly stable if I produce an APK using visual Studio 2017.
Visual Studio 2019 uses Xamarin.Andriod.SDK 12.0.0.3
Visual Studio 2017 uses Xamarin.Android.SDK 9.7.1.0
I have attempted to upgrade to Android 12 but our project is Huge and require significant amount of work. It does not seem to be an option at this point.
The reason I want to use 2019 or 2022 is because of google play store and producing app bundle instead of APK. Visual Studio 2017 does not have app bundle option.
My projects target Android 9 and I am also using PortSip Libraries. I have done extensive googling. I have not found any solid evidence if there is a problem with Xamarin Android SKD in 2019 or a problem with my Samsung Device Tab S6. The only answer I found here is:
Why application is dying randomly?
If this the case why an APK produced by 2017 does not have any segmentation faults or any race conditions.
I have handlers in c# to catch any error but non of them catches these. My app uses google MAPs and we are drawing many layers and updates on the MAP.
My app also receives many signalr updates and makes calls to WCF services.
Examples of errors:
03-09 19:54:53.811 9984 12254 F libc : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x40000000080 in tid 12254 (Thread Pool Wor), pid 9984 (------)
03-09 19:54:53.836 12404 12404 E chromium: [0309/195453.835730:ERROR:scoped_ptrace_attach.cc(27)] ptrace: Operation not permitted (1)
03-11 00:35:05.469 27236 27236 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7c13725238
We had a very similar problem with PortSip (null reference exception that was caused by the Garbage Collection thread in PortSip). We found that the problem was in the way a key class PortSip constructor contained mutual references with other classes. When those classes were disposed a null reference exception occurred on the garbage collection thread.
You reported that "I have handlers in C# to catch any error but none of them catches these". We found that to be the case as well. It turned out that since the crash was happening on the CG thread inside the PortSip library - adding error handling in C# had no effect.
If your crashes are also experiencing these symptoms - I will dig into the code and document our fix.

libc : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x7129621350 in tid 29032 (AudioRecord)

I'm developing a voip app using PJSIP 2.8. Recently I've moved to aab package approach and providing support for 64 bit device so when my device run on 64 bit device "arm64-v8a" it crashed during the call with this error
libc : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x7129621350 in tid 29032 (AudioRecord)
It worked fine if i prepare a apk and remove ndk filter from gradle.
Any help is much appreciated.

SIGSEGV crash with Firebase MLKit barcode scanner

I recently ran into a problem with my application: a weird crash happens when scanning QR codes coming from a particular website.
Anything generated by https://businesscards.tec-it.com/it causes a SIGSEGV crash with the following line in the logcat:
Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 19717
(FirebaseMLHandl), pid 19583 (is.qrsync.debug)
I am using Firebase ML Kit version 16.0.0 and it works fine with, so far, any other QR code generator.
Is this a known issue? How can I investigate this further?
Thanks

can't find NDK-STACK.html in sdk\ndk-bundle folder

I also tried to run ndk-stack.cmd, but this did nothing. Does someone know how can I find it? I need it to see about the Fatal signal 11 (SIGSEGV), code 2, fault addr 0xa2a23804 in tid 3819 (RenderThread) error I get at runtime.
This is a bug in NDK. Once upon a time, all NDK docs were distributed in the same zip. Today you will find the guide online: https://developer.android.com/ndk/guides/ndk-stack.html.

Categories

Resources