Issue 8784 - SIGBUS in mdb_page_touch
Summary: SIGBUS in mdb_page_touch
Status: UNCONFIRMED
Alias: None
Product: LMDB
Classification: Unclassified
Component: liblmdb (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-07 17:19 UTC by balaret@gmail.com
Modified: 2020-07-27 17:41 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description balaret@gmail.com 2017-12-07 17:19:48 UTC
Full_Name: Sergey Z
Version: LMDB_0.9.19
OS: Android
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (2620:119:5001:2242:9215:2763:ff1b:ae35)


Hey guys,

We are using LMDB 0.9.19 in our Android project and sometimes we are getting
SIGBUS in mdb_page_touch(). We can't reproduce this issue on our side but we
have plenty of crash reports from our users (about 400 daily):

SIGBUS
	libLMDBAndroid.so.mdb_page_touch ( mdb .c :2412)
	libLMDBAndroid.so.mdb_page_search ( mdb .c :5610)
	libLMDBAndroid.so.mdb_freelist_save ( mdb .c :3128)
	libLMDBAndroid.so.mdb_txn_commit ( mdb .c :3606)

This is probably a platform specific issue because 95% of crashes happened on
Android 7.0. 

I would greatly appreciate if you help to shed a light on this - any ideas what
might goes wrong or what might cause such an issue.

Thank you,
Sergey
Comment 1 Howard Chu 2017-12-08 18:35:14 UTC
balaret@gmail.com wrote:
> Full_Name: Sergey Z
> Version: LMDB_0.9.19
> OS: Android
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (2620:119:5001:2242:9215:2763:ff1b:ae35)
> 
> 
> Hey guys,
> 
> We are using LMDB 0.9.19 in our Android project and sometimes we are getting
> SIGBUS in mdb_page_touch(). We can't reproduce this issue on our side but we
> have plenty of crash reports from our users (about 400 daily):
> 
> SIGBUS
> 	libLMDBAndroid.so.mdb_page_touch ( mdb .c :2412)
> 	libLMDBAndroid.so.mdb_page_search ( mdb .c :5610)
> 	libLMDBAndroid.so.mdb_freelist_save ( mdb .c :3128)
> 	libLMDBAndroid.so.mdb_txn_commit ( mdb .c :3606)
> 
> This is probably a platform specific issue because 95% of crashes happened on
> Android 7.0.
> 
> I would greatly appreciate if you help to shed a light on this - any ideas what
> might goes wrong or what might cause such an issue.

I've encountered this as well. I believe there's a bug in the Android FUSE 
filesystem driver. Every time I've analyzed one of these crashes in the 
debugger, the relevant addresses are perfectly valid, which leads me to 
believe there's a race condition in their page fault handler. I.e., eventually 
the handler returns a valid memory page but the application has been killed 
before the handler completes. Then, by the time the debugger gets control, all 
of memory looks valid.

If you root the device and mount the storage partition directly, bypassing the 
Android FUSE filesystem, you'll find that these crashes all disappear - even 
if using the same storage device as before. Which again points to a bug in 
their FUSE filesystem driver. But I haven't been able to pinpoint the bug in 
their FUSE driver source code yet. I suggest you focus your debugging efforts 
there.
> 
> Thank you,
> Sergey
> 
> 


-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

Comment 2 stefan.penner 2020-07-27 17:08:13 UTC
I realize this issue is rather old, but I have some related questions; hopefully that is alright:

* The reporter mentions Android 7, do we know if the problem is limited to Android 7, or do other Androids also suffer from this issue?
* Was someone able to come up with a consistent reproduction? If so, could it be shared or described?
Comment 3 Howard Chu 2020-07-27 17:41:12 UTC
(In reply to stefan.penner from comment #2)
> I realize this issue is rather old, but I have some related questions;
> hopefully that is alright:
> 
> * The reporter mentions Android 7, do we know if the problem is limited to
> Android 7, or do other Androids also suffer from this issue?
> * Was someone able to come up with a consistent reproduction? If so, could
> it be shared or described?

I'm not aware of any consistent reproducer. Also, haven't run into this in quite a while, possibly it was already fixed in Android 9 or so