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

jnigen SIGABRT when called with null object #1868

Open
brianquinlan opened this issue Jan 6, 2025 · 1 comment
Open

jnigen SIGABRT when called with null object #1868

brianquinlan opened this issue Jan 6, 2025 · 1 comment

Comments

@brianquinlan
Copy link
Contributor

This code:

    final privateKey = keyStore.getEntry('test-combined'.toJString(),
        bindings.KeyStore_ProtectionParameter.fromReference(jNullReference));
    print('>>> PRIVATE KEY: ${privateKey.getAttributes()}');

Leads to this failure:

JNI DETECTED ERROR IN APPLICATION: can't call java.util.Set java.security.KeyStore$Entry.getAttributes() on null object
F/ok_http_example( 6573): runtime.cc:716]     in call to CallObjectMethodV
F/libc    ( 6573): Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 6602 (1.ui), pid 6573 (ok_http_example)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/sdk_gphone64_arm64/emu64a:15/AE3A.240806.036/12592187:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2025-01-06 11:34:42.468317417-0800
Process uptime: 737s
Cmdline: com.example.ok_http_example
pid: 6573, tid: 6602, name: 1.ui  >>> com.example.ok_http_example <<<
uid: 10229
tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
pac_enabled_keys: 000000000000000f (PR_PAC_APIAKEY, PR_PAC_APIBKEY, PR_PAC_APDAKEY, PR_PAC_APDBKEY)
signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
Abort message: 'JNI DETECTED ERROR IN APPLICATION: can't call java.util.Set java.security.KeyStore$Entry.getAttributes() on null object
    in call to CallObjectMethodV'

The method being called is KeyStore.getEntry().

The generated Dart code:

  static final _getEntry = _$jni.ProtectedJniExtensions.lookup<
          _$jni.NativeFunction<
              _$jni.JniResult Function(
                  _$jni.Pointer<_$jni.Void>,
                  _$jni.JMethodIDPtr,
                  _$jni.VarArgs<
                      (
                        _$jni.Pointer<_$jni.Void>,
                        _$jni.Pointer<_$jni.Void>
                      )>)>>('globalEnv_CallObjectMethod')
      .asFunction<
          _$jni.JniResult Function(
              _$jni.Pointer<_$jni.Void>,
              _$jni.JMethodIDPtr,
              _$jni.Pointer<_$jni.Void>,
              _$jni.Pointer<_$jni.Void>)>();

  /// from: `public final java.security.KeyStore$Entry getEntry(java.lang.String string, java.security.KeyStore$ProtectionParameter protectionParameter)`
  /// The returned object must be released after use, by calling the [release] method.
  KeyStore_Entry getEntry(
    _$jni.JString string,
    KeyStore_ProtectionParameter protectionParameter,
  ) {
    return _getEntry(reference.pointer, _id_getEntry as _$jni.JMethodIDPtr,
            string.reference.pointer, protectionParameter.reference.pointer)
        .object(const $KeyStore_Entry$Type());
  }
@HosseinYousefi
Copy link
Member

It seems that keyStore.getEntry returns null. Latest version of jnigen generates the code in a null-safe way based on the annotations on the underlying Java code.

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

No branches or pull requests

2 participants