Я пытаюсь выполнить приведенный ниже код на Android.
Архитектура: arm64-v8a Редакция NDK: 15.2.4203891
Я также предоставил write_external_storage
разрешения.
FILE *pFile = fopen("/data/myfile.txt", "a");
fprintf(pFile, "HELLO WORLD!");
fflush(pFile);
fclose(pFile);
Это происходит сбой с этой ошибкой:
2-13 03:08:27.013 27451-27451/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x58 in tid 27451 (ample.hellolibs), pid 27451 (ample.hellolibs)
02-13 03:08:27.076 27485-27485/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'Android/aosp_angler/angler:8.1.0/OPM3.171019.013/tcs02091522:userdebug/test-keys'
Revision: '0'
ABI: 'arm64'
pid: 27451, tid: 27451, name: ample.hellolibs >>> com.example.hellolibs <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x58
Cause: null pointer dereference
x0 0000000000000000 x1 0000007d249a7817 x2 0000007fffdcc440 x3 00000000000001b6
x4 0000007fffdcc5b0 x5 0000007d3b83ea74 x6 0000007fffdcc7b0 x7 0000000070a5cbf0
x8 0afac3eeec53c751 x9 0000007fffdcc4b0 x10 0000007fffdcc468 x11 0000007fffdcc410
02-13 03:08:27.077 27485-27485/? A/DEBUG: x12 0000007fffdcc418 x13 3a10de56bba1753f x14 0000007dc0289000 x15 ffffffffffffffff
x16 0000007dbf86a4b0 x17 0000007dbf7f5138 x18 0000000000000010 x19 0000000000000000
x20 0000007fffdcc440 x21 0000007d249a7817 x22 0000007dc08c1a40 x23 0000007dbd88c290
x24 0000000000000004 x25 0000007dc08c1a40 x26 0000007d3bcbeaa0 x27 0000000000000001
x28 0000007fffdcc510 x29 0000007fffdcc370 x30 0000007dbf8163c0
sp 0000007fffdcc320 pc 0000007dbf7f5164 pstate 0000000060000000
02-13 03:08:27.195 27485-27485/? A/DEBUG: backtrace:
#00 pc 0000000000056164 /system/lib64/libc.so (vfprintf+44)
#01 pc 00000000000773bc /system/lib64/libc.so (fprintf+112)
02-13 03:08:27.196 27485-27485/? A/DEBUG: #02 pc 000000000000077c /data/app/com.example.hellolibs-5RHGoggEKPs6kq-HxHOb1w==/lib/arm64/libhello-libs.so (Java_com_example_hellolibs_MainActivity_stringFromJNI+64)
#03 pc 0000000000553bf0 /system/lib64/libart.so (art_quick_generic_jni_trampoline+144)
#04 pc 000000000054ab88 /system/lib64/libart.so (art_quick_invoke_stub+584)
#05 pc 00000000000dc594 /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+204)
#06 pc 000000000029b49c /system/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+344)
#07 pc 0000000000295a90 /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+700)
#08 pc 0000000000532ad8 /system/lib64/libart.so (MterpInvokeVirtual+652)
#09 pc 000000000053c914 /system/lib64/libart.so (ExecuteMterpImpl+14228)
ndk-стек дает следующий вывод:
s/app/build/intermediates/cmake/arm8/debug/obj/arm64-v8a/libhello-libs.so
********** Crash dump: **********
Build fingerprint: 'samsung/c7proltedd/c7prolte:7.0/NRD90M/C701FDDU1BRC2:user/release-keys'
pid: 23318, tid: 23318, name: tify.newjnilibc >>> com.lenovo.notify.newjnilibc <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Stack frame #00 pc 000000000006c5b4 /system/lib64/libc.so (tgkill+8)
Stack frame #01 pc 0000000000069a38 /system/lib64/libc.so (pthread_kill+64)
Stack frame #02 pc 0000000000024a00 /system/lib64/libc.so (raise+24)
Stack frame #03 pc 000000000001cdac /system/lib64/libc.so (abort+52)
Stack frame #04 pc 000000000042ed2c /system/lib64/libart.so