realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.75k forks source link

Permission denied in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm #7662

Closed RealMoMo closed 1 year ago

RealMoMo commented 2 years ago

How frequently does the bug occur?

All the time

Description

Realm.getDefaultInstance() crash Is it caused by selinux?

Stacktrace & log output

2022-03-15 11:42:53.814 6406-6406/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.dss.floatball, PID: 6406
    java.lang.RuntimeException: Unable to create service com.dss.floatball.ui.floatball.service.FloatBallService: java.lang.RuntimeException: Permission denied in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 107
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3544)
        at android.app.ActivityThread.access$1300(ActivityThread.java:199)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1666)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:860)
     Caused by: java.lang.RuntimeException: Permission denied in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 107
        at io.realm.internal.OsSharedRealm.nativeGetSharedRealm(Native Method)
        at io.realm.internal.OsSharedRealm.<init>(OsSharedRealm.java:176)
        at io.realm.internal.OsSharedRealm.getInstance(OsSharedRealm.java:261)
        at io.realm.BaseRealm.<init>(BaseRealm.java:143)
        at io.realm.BaseRealm.<init>(BaseRealm.java:110)
        at io.realm.Realm.<init>(Realm.java:159)
        at io.realm.Realm.createInstance(Realm.java:506)
        at io.realm.RealmCache.createInstance(RealmCache.java:508)
        at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:461)
        at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:422)
        at io.realm.Realm.getDefaultInstance(Realm.java:414)
        at com.dss.floatball.data.function.RealmDatabaseRepository.<init>(RealmDatabaseRepository.kt:38)
        at com.dss.floatball.data.function.FunctionRepository.<init>(FunctionRepository.kt:45)
        at com.dss.floatball.data.function.FunctionRepository.<init>(Unknown Source:0)
        at com.dss.floatball.data.function.FunctionRepository$Companion.getInstance(FunctionRepository.kt:31)
        at com.dss.floatball.ui.floatball.FloatBallServiceDelegatePresenter.<init>(FloatBallServiceDelegatePresenter.kt:26)
        at com.dss.floatball.ui.floatball.service.FloatBallServiceViewDelegate.<init>(FloatBallServiceViewDelegate.kt:120)
        at com.dss.floatball.ui.floatball.service.FloatBallService.onCreate(FloatBallService.kt:41)
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3532)
        at android.app.ActivityThread.access$1300(ActivityThread.java:199) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1666) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6669) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:860) 

Can you reproduce the bug?

Yes, always

Reproduction Steps

No response

Version

"io.realm:realm-gradle-plugin:6.0.2"(10.11.0 aslo crash)

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

Android9.0

Build environment

Android Studio version: ... Android Build Tools version: ... Gradle version: ...

KimiChiu commented 2 years ago

I have the same problem after I copy the realm file by file system and replace the original one.

clementetb commented 2 years ago

@RealMoMo the error you experience is Realm failing to open the file, it might be caused by different issues. We need more context about the error to be able to point to the issue.

Is this error something new, was it working before? If not what have you changed? Are you fiddling with the Realm file? Is it a multiprocess app? Do you use Instant apps?

@KimiChiu Please use the RealmConfiguration::assetFile method If you like to load a DB from disk.

edualonso commented 1 year ago

Closing due to inactivity. Please reopen if it is still an issue.