App crashes (sometimes) with Fatal signal 11 (SIGSEGV), code 1
Asked Answered
B

3

19

I am developing an app with the HERE SDK, and everything worked fine until now. I get errors like this one:
Fatal signal 11 (SIGSEGV), code 1, fault addr 0x750057 in tid 10206 (FinalizerDaemon)
or this one:
Fatal signal 11 (SIGSEGV), code 1, fault addr 0x94789680 in tid 24605 (FinalizerDaemon)

and they make my app crash.

It's not always the same errors, but they always come all alone in my Logcat,with no other information.

In all my app I am using HERE objects and services, and even by printing the stacktrace I don't get more information about the errors.
I just noticed that these errors appear pretty much randomly, but only when I am using these objects/services.

I use a real device to test my app, a Sony Xperia Z3 compact, so I don't think it comes from here.

I am really lost, so if someone has any idea even on how to get more infos about the errors, please help

EDIT:

 05-09 23:04:10.148 6770-6782/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x4 in tid 6782 (FinalizerDaemon)
05-09 23:04:10.266 30179-30179/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-09 23:04:10.266 30179-30179/? I/DEBUG: UUID: 5569a1b9-c913-4101-99fa-5099e2cadd48
05-09 23:04:10.266 30179-30179/? I/DEBUG: Build fingerprint: 'Sony/D5803/D5803:5.1.1/23.4.A.1.264/2418263178:user/release-keys'
05-09 23:04:10.266 30179-30179/? I/DEBUG: Revision: '0'
05-09 23:04:10.266 30179-30179/? I/DEBUG: ABI: 'arm'
05-09 23:04:10.266 30179-30179/? I/DEBUG: pid: 6770, tid: 6782, name: FinalizerDaemon  >>> com.david.metroz <<<
05-09 23:04:10.266 30179-30179/? I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4
05-09 23:04:10.294 30179-30179/? I/DEBUG:     r0 98327400  r1 00000000  r2 00000002  r3 00000000
05-09 23:04:10.294 30179-30179/? I/DEBUG:     r4 aec264c0  r5 b3df7acc  r6 98327400  r7 73652348
05-09 23:04:10.294 30179-30179/? I/DEBUG:     r8 6f9983a8  r9 b482a800  sl 12f1d820  fp b3df7abc
05-09 23:04:10.294 30179-30179/? I/DEBUG:     ip b5303950  sp b3df7ab0  lr b510717f  pc a0b7205c  cpsr a00e0010
05-09 23:04:10.294 30179-30179/? I/DEBUG:     #00 pc 000f405c  /data/app/com.david.metroz-1/lib/arm/libMAPSJNI.so (Java_com_nokia_maps_GeoBoundingBoxImpl_destroyNative+76)
05-09 23:04:10.294 30179-30179/? I/DEBUG:     #01 pc 001d7d4f  /data/dalvik-cache/arm/data@[email protected]@[email protected]
05-09 23:04:12.302 862-1274/? E/NativeCrashListener: Exception dealing with report
                                                     android.system.ErrnoException: read failed: EAGAIN (Try again)
                                                         at libcore.io.Posix.readBytes(Native Method)
                                                         at libcore.io.Posix.read(Posix.java:165)
                                                         at libcore.io.BlockGuardOs.read(BlockGuardOs.java:230)
                                                         at android.system.Os.read(Os.java:350)
                                                         at com.android.server.am.NativeCrashListener.consumeNativeCrashData(NativeCrashListener.java:240)
                                                         at com.android.server.am.NativeCrashListener.run(NativeCrashListener.java:138)

EDIT 2: I am now pretty sure that the crash happens when I am retrieving HERE objects from database using gson.

The following code works when everything is done in the same app runtime, but when I save a string in the database, close the app and then re-open it, I get the Fatal signal while converting the json string back to the object.

// to insert I create a json string and then insert it in the database
String mGbSortie = gson.toJson(geoboundinBox);

//and then to retrieve the data :
Type gbType = new TypeToken<GeoBoundingBox>(){}.getType();
geoBoudingBox = gson.fromJson(stringFromDb, listType)

I really don't know why it doesn't work.

Birth answered 8/5, 2016 at 15:36 Comment(1)
now i am having the same issue. I have an app and randomly changing fragments. it shows me the same error on app crashing but it is very random behaviour means there is no pattern for this. but it gets crashedMcwhorter
S
8

1) Firstly determine whether it's a bug within the android, the third party libraries or your device, so you can know which way to proceed.

This answer gives a solution of how to do this:

If you have written (or are using) a plugin that in turn uses native C/C++ code through the NDK, this may indicate a bug in that native code.

Otherwise, this is a bug in the firmware of the device or emulator you are testing upon.

If you can reproduce this in an emulator, on a Nexus device with the original ROM, or on a variety of devices from different manufacturers, it is probably a bug in Android itself. In that case, please create a sample project that can reproduce the error, and post it along with the entire stack trace to http://b.android.com, the Android OS issue tracker.

If you are only encountering this on one device or one third-party ROM, it is probably a more specific bug -- your best bet is to contact the device manufacturer or ROM publisher with your symptoms.

There are these two questions which discuss the error you are receiving in detail:

Android Fatal signal 11 (SIGSEGV) at 0x636f7d89 (code=1). How can it be tracked down?

Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1) - PhoneGap

2) In terms of parsing your geobounds values (as it would seem is where the problem may lie), ensure you are handling your parsing between Gson and Json correctly, with the correct geobound values. It appears how you are storing the values is not in accord with how you are retreiving them.

From Mykong:

toJson() – Convert Java object to JSON

Gson gson = new Gson();
Staff obj = new Staff();

// 1. Java object to JSON, and save into a file
gson.toJson(obj, new FileWriter("D:\\file.json"));

// 2. Java object to JSON, and assign to a String
String jsonInString = gson.toJson(obj);

fromJson() – Convert JSON to Java object

Gson gson = new Gson();

// 1. JSON to Java object, read it from a file.
Staff staff = gson.fromJson(new FileReader("D:\\file.json"), Staff.class);

// 2. JSON to Java object, read it from a Json String.
String jsonInString = "{'name' : 'mkyong'}";
Staff staff = gson.fromJson(jsonInString, Staff.class);

// JSON to JsonElement, convert to String later.
JsonElement json = gson.fromJson(new FileReader("D:\\file.json"), JsonElement.class);
String result = gson.toJson(json);

From this answer:

public class YourObject {
   private String appname;
   private String Version;
   private String UUID;
   private String WWXY;
   private String ABCD;
   private String YUDE;
   //getters/setters


YourObject parsed = new Gson().fromJson(jsons, YourObject.class);  

String jsons = "{'appname':'application', 'Version':'0.1.0', 'UUID':'300V', 'WWXY':'310W', 'ABCD':'270B', 'YUDE':'280T'}";
YourObject parsed = new Gson().fromJson(jsons, YourObject.class);  

JsonObject object = new JsonParser().parse(jsons).getAsJsonObject();
object.get("appname"); // application 
object.get("Version"); // 0.1.0

These SO questions give more details:
How to parse json parsing Using GSON in android
parse JSON with gson and GsonBuilder()

3) Ensure you are passing the correct values for your geobound co-ords. This question Value does not fall within the expected range GeoboundingBox WinRT (although it is C# gives a good example of how to break down the components of information you are trying to store and retrieve.

The answer is straightforward.

var nw = new BasicGeoposition();
nw.Latitude = Max(pos.Coordinate.Latitude, pos2.lat);
nw.Longitude = Min(pos.Coordinate.Longitude, pos2.lng);
var se = new BasicGeoposition();
se.Latitude = Min(pos.Coordinate.Latitude, pos2.lat);
se.Longitude = Max(pos.Coordinate.Longitude, pos2.lng);

And learn how to parse your json with gson:

Use Gson to work with JSON in your Android apps

There is also this gihub repo for you to browse for more ideas.

Sforza answered 17/5, 2016 at 14:47 Comment(0)
F
2

Can you paste any more info from adb logcat? It is currently not enough information for us to help you out. A segfault in the finalizer daemon can imply double deletion of native objects. Without more information, it could be anywhere in the OS or in the SDK.

The skipped frames means your app is processing lots of data in the main thread. Skipping 161 frames means over 3s of busy time! Please try to use AsyncTasks or threads to optimize your app.

It seems you are using GSON type deserializer, which will not construct our native objects correctly. Manually deserializing the lat, lng and calling new GeoBoundingBox() will not crash.

Freaky answered 9/5, 2016 at 4:27 Comment(12)
I edited my question, but I think I have found the problem : I am using the gson library to convert a list of geocoordinates and a geoboundingbox into a json string, and I think sometimes the string is not well created, so trying to get the object back with that wrong string messes up, a bit like thisBirth
That is a possibility, but just having a quick check of the code I do not see how you would have an invalid pointer with that stack. Can you post the coordinates of the bounding box that crashes?Freaky
Well it crashes with every coordinates I try, but you can take a look at them if you want : gb: right = Lat: 48.86490904039134, Long: 2.39895392405874, Alt: 0.0 left = Lat: 48.864913, Long: 2.3988175, Alt: 0.0 center= Lat: 48.86491102019567, Long: 2.3988857120293696, Alt: 1.073741824E9 .Birth
I added some code, do you have any idea why it's not working ?Birth
Seems you are constructing our geo bounding box without using the normal constructor? Very likely your bounding box code is not calling through to the main constructor in the native code, so effectively it created a corrupt object. Can you please deserialize the lat, lng and manually call new GeoBoundingBox() ?Freaky
I can't deserialize the lat and lng manually, because I am serializing the whole geo bounding box, so when I deserialize it I can't access the lat and lng as the object is already corrupted. But what I don't understand is that my code is working well when I serialize and deserialize one geo bounding box in the same app launch. It crashes only when I serialize, close app, re-open app, and deserialize. Looks like the object "dies" or something and can't be re-created.Birth
Yeah, because you are trying to deserialize a native object :) The underlying geobounding box object is backed by a native pointer. So all you were serializing out was a C++ pointer to somewhere in memory. Serialize it as a lat long public class and it should work.Freaky
Well thank you very much for the explanations. However this is causing me much more trouble than I tought because I am also saving big List<Geocoordinate>, which are actually route geometries. I guess I'll have to store them as lists of lat lng objects as you suggested... Anyway thank you againBirth
I down voted it because it is not the correct answer. It contains lots of information that is not relevant. Not looking for the bounty, just trying to make the SDK better. PS: I'm one of the original authors of the HERE SDK :)Freaky
Alright that's why you always answer my HERE questions ! I undersand for the downvote, I realised after that the problem was not because of Gson. Thank you again for your timeBirth
Thanks for your useful post. Saved me a lot of hoursCaesar
Hi I am having the same issue can up please look into it #54760808Butanone
D
1

I have resolved same issue by following code.

Add android:vmSafeMode="true" in application tag in Manifest file.

Your application tag should looks like:

<application
    android:name=".MyApplication"
    android:hardwareAccelerated="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:theme="@style/AppTheme"
    android:vmSafeMode="true">

    // Other stuff

 </application>

Hope this will help you.

Dibromide answered 18/5, 2016 at 12:13 Comment(3)
I don't know how, but this avoids the Fatal signal, however as @DavidLeong said I was serializing a C++ pointer, so when I closed and re-opened the app, the pointer was null. I can see it better now because instead of getting the error I get the object with null coordinates : 0,000000,0,000000;0,000000,0,000000Birth
I would not recommend to do this. It may be hiding the problem and ultimately corrupting the C++ heap.Freaky
it will block usb connections. in my case , it blocked usb connectionJeer

© 2022 - 2024 — McMap. All rights reserved.