Repository navigation
Description
7.1.0 crashes the target process on Android 16 QPR2 and Android 17 when an object array is converted from Java to JavaScript (a return value, or an argument of a replaced method) or created with Java.array(). 7.0.13 does not. The crash comes from the GetFieldID probe that a342d5e restored to fix #408: on newer ART, GetFieldID on an array class dereferences null.
The Object.hashCode() probe from #403, which is planned to land first, fixes it. Applied on its own to 7.1.0 it passes every case below, and #408 stays fixed.
Reproduction
Frida 17.26.3 and frida-java-bridge 7.1.0, attached to a running app on the Android 17 emulator (system-images;android-37.0;google_apis;x86_64):
Java.perform(() => {
const fields = Java.use('java.lang.String').class.getDeclaredFields();
console.log(fields.length);
});Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x10
#00 art::mirror::Class::FindInstanceField(std::string_view, std::string_view)+182
#01 art::FindFieldJNI(art::ScopedObjectAccess const&, _jclass*, char const*, char const*, bool, void*)+712
#02 art::JNI<false>::GetFieldID(_JNIEnv*, _jclass*, char const*, char const*)+684
Cause
_make() calls ensureClassInitialized() for every class it wraps, including the array class of an object array. Since a342d5e that calls GetFieldID(cls, "x", "Z").
ART commit 234948adf3d1 ("Make the class's field array never null", in AOSP since Android 16 QPR1) gives array classes a shared zero-length field array instead of null, in FinishArrayClassSetup(). Class::FindDeclaredField() still returns early only when that array is null, and otherwise calls GetDexFile(). Array classes have no DexCache, so that dereferences null; 0x10 is the offset of DexCache::dex_file_.
This is an ART bug: GetFieldID() on an array class should throw NoSuchFieldError.
Fix options
Stock Frida 17.26.3 on three x86_64 emulator images, each case in a fresh process:
| Case | 7.0.13 | 7.1.0 | 7.1.0 + #403's probe | 7.1.0 + array guard |
|---|---|---|---|---|
Object arrays: return value, argument of a replaced method, Java.array() |
OK | crash | OK | OK |
| Primitive arrays | OK | OK | OK | OK |
Static set to 42 by <clinit>, read right after Java.use() (the #408 check) |
0 | 42 | 42 | 42 |
The crashes are on Android 16 QPR2 (ART 361153460) and Android 17 (ART 370546200). The original Android 16 image (ART 360527520) does not have the ART commit and does not crash. The other rows are the same on all three images.
-
added support for hooking class initializers #403's probe here means only its
ensureClassInitialized()change:GetMethodID(cls, "hashCode", "()I")instead ofGetFieldID(cls, "x", "Z"), with the_make()call left in place. Method lookup does not go through the field code above. -
Array guard is the smaller alternative, in
_make()inlib/class-factory.js. Array classes have nothing to initialize:- ensureClassInitialized(env, classHandle); + if (name[0] !== '[') { + ensureClassInitialized(env, classHandle); + }
I can open a PR for either, and I can run any candidate on these images. CI runs API 26 to 31 only, so it cannot hit this, although replacementCanAcceptStringArrayParameter and genericArrayTypeShouldConvertToArray already exercise the crashing path.
Notes
- I ran these through my own harness (the bridge bundled with rollup and loaded ahead of each script), not the repository's JUnit suite.
- Also seen on a Pixel 10 Pro (arm64, Android 16, ART 372042720) with a 7.0.10-era bridge, which has the same probe.
Activity
ilkecan commentedon Nov 18, 2026
Also reproduced on a physical arm64 device on Android 17: Pixel (
google/mustang), GrapheneOS buildCP3A.261005.005, Frida Gadget 17.27.0, frida-java-bridge 7.1.0.Trigger:
Java.array('java.lang.String', [...])insideJava.perform().The array guard in
_make()(skippingensureClassInitialized()when the class name starts with[) fixes it on this device. Pinning to 5c578e7, the parent of a342d5e, works as well.Update Frida Gadget to 17.27.0 and pin frida-java-bridge to a commit …
fix: Update Frida Gadget to 17.27.0 and pin frida-java-bridge to a co…