Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashes during QR code generation #29

Open
jonahbeckford opened this issue Feb 8, 2025 · 2 comments
Open

Crashes during QR code generation #29

jonahbeckford opened this issue Feb 8, 2025 · 2 comments

Comments

@jonahbeckford
Copy link
Contributor

When debugging through com.example.squirrelscout_scouter.ui.viewmodels.ScoutingSessionViewModel#generateQrCode, get a SIGSEGV at:

art_sigsegv_fault 0x00000078e6b410b0
art::FaultManager::HandleFault(int, siginfo*, void*) 0x00000078e6b415e4
art::SignalChain::Handler(int, siginfo*, void*) 0x0000005b240dcea0
<unknown> 0x0000007b7dd27678
st_tls_get 0x00000078d4c4fec0
caml_thread_leave_blocking_section 0x00000078d4c4febc
caml_leave_blocking_section 0x00000078d4e2bae8
memmove_blocking_section ffi_bytes.c:80
dksdk_ffi_ocaml_hostsegment_blit_from_bytes ffi_bytes.c:140
caml_c_call 0x00000078d4e4fc78
camlDkSDKFFI_OCaml__HostStorage__blit_from_string_702 SonicScoutAndroid:104
camlCapnp__BuilderInc__uint8_list_of_string_4485 SonicScoutAndroid:78
camlCapnp__BuilderInc__set_blob_5641 SonicScoutAndroid:849
camlObjsEntry__qr_code_of_raw_match_data_4087 SonicScoutAndroid:56
camlDkSDKFFI_OCaml__Com__g_5562 SonicScoutAndroid:459
caml_start_program 0x00000078d4e4fce8
caml_callback2_exn 0x00000078d4e44df4
execute_helper dksdk_ffi_ocaml_callback.c:177
dksdk_ffi_c_cls_generic_method_dispatch dksdk_ffi_c_cls_generic.c:385
Java_com_diskuv_dksdk_ffi_java_jn_c_NativeCLib_native_1dk_1cls_1call_1method_1execute NativeCLib.c:754
art_quick_generic_jni_trampoline 0x00000078e6a43ed8
<unknown> 0x00000078e6a44210
@jonahbeckford
Copy link
Contributor Author

However, when set a breakpoint in dksdk-ffi-ocaml/src/DkSDKFFI_OCaml/core/ffi_bytes.c:129 (dksdk-ffi-ocaml/src/DkSDKFFI_OCaml/core/ffi_bytes.c) then QR code is generated.

Which sounds like the CAML thread or a CAMLparam is incorrect during dksdk_ffi_ocaml_hostsegment_blit_from_bytes when leaving the blocking section at:

    memmove_blocking_section(src_data, src_pos, dst_data, dst_pos, len);

@jonahbeckford
Copy link
Contributor Author

Possible solutions:

But from the stack trace the real culprit may be that the Android JNI thread is not registered as an (OCaml) pthread:

Caml_inline void * st_tls_get(st_tlskey k)
{
  return pthread_getspecific(k);
}

That is, https://pubs.opengroup.org/onlinepubs/009696799/functions/pthread_getspecific.html will:

The effect of calling pthread_getspecific() or pthread_setspecific() with a key value not obtained from pthread_key_create() or after key has been deleted with pthread_key_delete() is undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant