Segfault when starting Android service on Android 7.0



  • I'm trying to make a program that starts a service and it works fine on Android 5.1.1 (Nexus 4) however the service segfaults on my Android 7.0 (Samsung Galaxy S7) device. Both the service and the program lives in the same file and the service starts if the '-service' command line argument is present, also I'm using Qt 5.9.1 and Crystax NDK.

    My own service class looks like this (without the imports of course)

    public class MyService extends QtService {
        private static final String TAG = "MyService";
    
        @Override
        public void onCreate()
        {
            Log.w(TAG, "onCreate called");
            super.onCreate();
            Log.w(TAG, "onCreate finished");
        }
    
        @Override
        public int onStartCommand(Intent intent, int flags, int startId)
        {
            Log.w(TAG, "onStartCommand called");
            int retval = super.onStartCommand(intent, flags, startId);
            Log.w(TAG, "onStartCommand finished with: " + retval);
            return retval;
        }
    }
    
    

    This is the interesting part of adb logcat

    01-04 16:01:24.794  3724  4025 D MdnieScenarioControlService:  packageName : org.qtproject.example    className : org.my.MyActivity
    01-04 16:01:24.938 31180 31211 D         : (null):0 ((null)): 2018-01-04 15:01:24,937 - my - INFO - Starting
    01-04 16:01:24.938 31180 31211 D         : (null):0 ((null)): 2018-01-04 15:01:24,938 - my - INFO - ['/data/app/org.qtproject.example-2/lib/arm/libMy.so']
    01-04 16:01:25.112  3724  4903 I ActivityManager: Start proc 31219:org.qtproject.example:qt_service_process/u0a243 for service org.qtproject.example/org.my.MyService
    01-04 16:01:25.113 31180 31211 D         : (null):0 ((null)): 2018-01-04 15:01:25,112 - my - INFO - iam client
    01-04 16:01:25.114 31219 31219 W SELinux : SELinux selinux_android_compute_policy_index : Policy Index[1],  Con:u:r:zygote:s0 SPD:SEPF_SECMOBILE_7.0_0006 RAM:SEPF_SECMOBILE_7.0_0005, [-1 -1 0 1 0 1]
    01-04 16:01:25.115 31219 31219 I SELinux : SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=org.qtproject.example:qt_service_process 
    01-04 16:01:25.116 31219 31219 I art     : Late-enabling -Xcheck:jni
    01-04 16:01:25.128 31219 31219 D TimaKeyStoreProvider: TimaSignature is unavailable
    01-04 16:01:25.128 31219 31219 D ActivityThread: Added TimaKeyStore provider
    01-04 16:01:25.129  3724  5116 I ActivityManager: DSS on for org.qtproject.example and scale is 1.0
    01-04 16:01:25.156 31219 31219 D ContextRelationMgrBrdg: loadKlass() : caller=com.samsung.android.bridge.multiscreen.common.ContextRelationManagerBridge.<clinit>:28 android.app.LoadedApk.makeApplication:840 
    01-04 16:01:25.162 31219 31219 W MyService: onCreate called
    01-04 16:01:25.166 31219 31219 E Qt      : extraLib: plugins/platforms/android/libqtforandroid.so
    01-04 16:01:25.166 31219 31219 E Qt      : extraLib: plugins/bearer/libqandroidbearer.so
    01-04 16:01:25.166 31219 31219 E Qt      : extraLib: lib/libQt5QuickParticles.so
    01-04 16:01:25.166 31219 31219 E Qt      : libName: My
    01-04 16:01:25.167 31219 31219 W System  : ClassLoader referenced unknown path: 
    01-04 16:01:25.169 31219 31219 W linker  : /data/data/org.qtproject.example/qt-reserved-files/plugins/platforms/android/libqtforandroid.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.169 31219 31219 W linker  : /data/app/org.qtproject.example-2/lib/arm/libQt5Gui.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.188 31219 31219 I Qt      : qt start
    01-04 16:01:25.189 31219 31219 I Qt      : Looking for custom activity class
    01-04 16:01:25.190 31219 31219 I Qt      : Custom activity lookup done
    01-04 16:01:25.191 31219 31219 W linker  : /data/data/org.qtproject.example/qt-reserved-files/plugins/bearer/libqandroidbearer.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.191 31219 31219 W linker  : /data/app/org.qtproject.example-2/lib/arm/libQt5Network.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.194 31219 31219 I QtCore  : Start
    01-04 16:01:25.195 31219 31234 E STDERR  : WARNING: linker: /data/data/org.qtproject.example/qt-reserved-files/plugins/bearer/libqandroidbearer.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.195 31219 31234 E STDERR  : WARNING: linker: /data/app/org.qtproject.example-2/lib/arm/libQt5Network.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.196 31219 31219 W linker  : /data/app/org.qtproject.example-2/lib/arm/libQt5QuickParticles.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.196 31219 31219 W linker  : /data/app/org.qtproject.example-2/lib/arm/libQt5Quick.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.196 31219 31234 E STDERR  : WARNING: linker: /data/app/org.qtproject.example-2/lib/arm/libQt5QuickParticles.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.196 31219 31234 E STDERR  : WARNING: linker: /data/app/org.qtproject.example-2/lib/arm/libQt5Quick.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.196 31219 31219 W linker  : /data/app/org.qtproject.example-2/lib/arm/libQt5Qml.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.196 31219 31219 W linker  : /data/app/org.qtproject.example-2/lib/arm/libQt5Qml.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.196 31219 31234 E STDERR  : WARNING: linker: /data/app/org.qtproject.example-2/lib/arm/libQt5Qml.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.196 31219 31234 E STDERR  : WARNING: linker: /data/app/org.qtproject.example-2/lib/arm/libQt5Qml.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.220 31219 31219 W linker  : /data/app/org.qtproject.example-2/lib/arm/libMy.so: unused DT entry: type 0xf arg 0x8ab35
    01-04 16:01:25.221 31219 31219 W linker  : /data/app/org.qtproject.example-2/lib/arm/libQt5Svg.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.221 31219 31234 E STDERR  : WARNING: linker: /data/app/org.qtproject.example-2/lib/arm/libMy.so: unused DT entry: type 0xf arg 0x8ab35
    01-04 16:01:25.221 31219 31234 E STDERR  : WARNING: linker: /data/app/org.qtproject.example-2/lib/arm/libQt5Svg.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.221 31219 31219 W linker  : /data/app/org.qtproject.example-2/lib/arm/libQt5Widgets.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.221 31219 31219 W linker  : /data/app/org.qtproject.example-2/lib/arm/libQt5AndroidExtras.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.221 31219 31219 W linker  : /data/app/org.qtproject.example-2/lib/arm/libQt5Widgets.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.221 31219 31234 E STDERR  : WARNING: linker: /data/app/org.qtproject.example-2/lib/arm/libQt5Widgets.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.221 31219 31234 E STDERR  : WARNING: linker: /data/app/org.qtproject.example-2/lib/arm/libQt5AndroidExtras.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.221 31219 31234 E STDERR  : WARNING: linker: /data/app/org.qtproject.example-2/lib/arm/libQt5Widgets.so: unsupported flags DT_FLAGS_1=0x81
    01-04 16:01:25.300 31219 31219 W MyService: onCreate finished
    --------- beginning of crash
    01-04 16:01:25.301 31219 31235 F libc    : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x1c in tid 31235 (service_process)
    01-04 16:01:25.301 31219 31219 W MyService: onStartCommand called
    01-04 16:01:25.301 31219 31219 W MyService: onStartCommand finished with: 1
    01-04 16:01:25.302  3098  3098 W         : debuggerd: handling request: pid=31219 uid=10243 gid=10243 tid=31235
    01-04 16:01:25.331  3253  3253 E audit   : type=1400 audit(1515078085.322:1251): avc:  denied  { search } for  pid=31236 comm="debuggerd" name="org.qtproject.example" dev="dm-1" ino=278596 scontext=u:r:debuggerd:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0 SEPF_SECMOBILE_7.0_0006
    01-04 16:01:25.331  3253  3253 E audit   : type=1300 audit(1515078085.322:1251): arch=40000028 syscall=322 per=8 success=no exit=-13 a0=ffffff9c a1=e93a5180 a2=20000 a3=0 items=0 ppid=3098 pid=31236 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="debuggerd" exe="/system/bin/debuggerd" subj=u:r:debuggerd:s0 key=(null)
    01-04 16:01:25.331  3253  3253 E audit   : type=1327 audit(1515078085.322:1251): proctitle="/system/bin/debuggerd"
    01-04 16:01:25.331  3253  3253 E audit   : type=1320 audit(1515078085.322:1251): 
    01-04 16:01:25.331  3253  3253 E audit   : type=1400 audit(1515078085.322:1252): avc:  denied  { search } for  pid=31236 comm="debuggerd" name="org.qtproject.example" dev="dm-1" ino=278596 scontext=u:r:debuggerd:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0 SEPF_SECMOBILE_7.0_0006
    01-04 16:01:25.331  3253  3253 E audit   : type=1300 audit(1515078085.322:1252): arch=40000028 syscall=322 per=8 success=no exit=-13 a0=ffffff9c a1=e93a52a0 a2=20000 a3=0 items=0 ppid=3098 pid=31236 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="debuggerd" exe="/system/bin/debuggerd" subj=u:r:debuggerd:s0 key=(null)
    01-04 16:01:25.331  3253  3253 E audit   : type=1327 audit(1515078085.322:1252): proctitle="/system/bin/debuggerd"
    01-04 16:01:25.331  3253  3253 E audit   : type=1320 audit(1515078085.322:1252): 
    01-04 16:01:25.409 31236 31236 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    01-04 16:01:25.409 31236 31236 F DEBUG   : Build fingerprint: 'samsung/hero2ltexx/hero2lte:7.0/NRD90M/G935FXXS1DQK6:user/release-keys'
    01-04 16:01:25.409 31236 31236 F DEBUG   : Revision: '9'
    01-04 16:01:25.409 31236 31236 F DEBUG   : ABI: 'arm'
    01-04 16:01:25.409 31236 31236 F DEBUG   : pid: 31219, tid: 31235, name: service_process  >>> org.qtproject.example:qt_service_process <<<
    01-04 16:01:25.410 31236 31236 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1c
    01-04 16:01:25.410 31236 31236 F DEBUG   :     r0 0000001c  r1 c79a1410  r2 fffffe14  r3 deef2cac
    01-04 16:01:25.410 31236 31236 F DEBUG   :     r4 eac55428  r5 def14530  r6 c8b88004  r7 00000002
    01-04 16:01:25.410 31236 31236 F DEBUG   :     r8 c79a14e0  r9 e788e390  sl c8c4b380  fp 00000058
    01-04 16:01:25.410 31236 31236 F DEBUG   :     ip eac4e85c  sp c79a1400  lr dee97224  pc eac0da06  cpsr 000d0030
    01-04 16:01:25.413 31236 31236 F DEBUG   : 
    01-04 16:01:25.413 31236 31236 F DEBUG   : backtrace:
    01-04 16:01:25.413 31236 31236 F DEBUG   :     #00 pc 00047a06  /system/lib/libc.so (pthread_mutex_lock+1)
    01-04 16:01:25.413 31236 31236 F DEBUG   :     #01 pc 00086220  /data/app/org.qtproject.example-2/lib/arm/libcrystax.so (puts+176)
    
    

    Any pointers what might be the problem? I'm no expert but it kinda looks like it fails because of the debugger.



  • @kviktor said in Segfault when starting Android service on Android 7.0:

    Crystax NDK

    Seems to crash inside that. Does it work with Google NDK ?



  • @oniongarlic Yes, looks like it does not crash with the official NDK (also some other weird error got fixed too with it so it's a win win)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.