bug(okhttp): Fatal SIGSEGV on Android 14+ JIT due to R8 optimization mismatch with OkHttp bytecode manipulation
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 48/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 領域
- build-system, mobile
研究方向
Start by reviewing sentry-android-core/proguard-rules.pro around lines 46-47 and the ASM logic in ResponseWithInterceptorChainMethodVisitor.kt, then reproduce the release build with R8 Full Mode on Android 14+. Trace whether the obsolete package rules leave io.sentry.okhttp and the manipulated RealCall path unprotected; done means the crash no longer occurs while HTTP instrumentation still works.
由索引模型根據 Issue 內容生成。
描述
Integration
sentry-okhttp
Build System
Gradle
AGP Version
8.x
Proguard
Enabled
Other Error Monitoring Solution
No
Version
8.53.0
Steps to Reproduce
- Enable Sentry HTTP Auto-Instrumentation in an Android project using the Sentry Android Gradle Plugin:
sentry { tracingInstrumentation { enabled = true features = [sentryOkHttpFeature] as Set } } - Compile the application in Release mode with R8 Full Mode enabled:
android.enableR8.fullMode=true - Run the compiled APK on any Android device running Android 14, 15, or 16 (equipped with updated Google Play Mainline ART modules).
- Trigger rapid concurrent network requests (e.g., loading a feed) to quickly increase the execution count of OkHttp's internal execution path, forcing the ART runtime to promote the method to a "hot method" and trigger JIT compilation.
Expected Result
The network calls complete smoothly and Sentry captures HTTP spans and breadcrumbs correctly without any native stability issues.
Actual Result
The background JIT compilation thread of ART (Android Runtime) crashes with a fatal native SIGSEGV (11) segmentation fault while compiling okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain(), causing the application process to die immediately.
Obfuscated Native Tombstone Stacktrace:
at __start_thread (<unknown>)
at __pthread_start (<unknown>)
...
at okhttp3.internal.connection.RealCall.G0 (<unknown>) # R8 optimized getResponseWithInterceptorChain
at io.sentry.okhttp.b.f (<unknown>) # Obfuscated SentryOkHttpEventListener
Detailed Technical Analysis
- ASM Bytecode Injection: The
sentry-android-gradle-pluginuses ASM bytecode manipulation (defined inResponseWithInterceptorChainMethodVisitor.kt) to inject a complexwhileloop that allocates registers/variables on the fly to detect and addSentryOkHttpInterceptorinside OkHttp'sokhttp3.internal.connection.RealCall.getResponseWithInterceptorChain(). - Missing / Obsolete Consumer Proguard Rules:
- The
sentry-okhttpmodule is packaged as a pure Java.jarlibrary, meaning it cannot ship native Android.aarconsumer proguard files. - The main
sentry-android-coremodule ships Proguard rules, but they are obsolete: they reference the old package nameio.sentry.android.okhttp.SentryOkHttpInterceptorinstead of the modernio.sentry.okhttp.SentryOkHttpInterceptor(refactored in v8.x). See line 46-47 in sentry-android-core/proguard-rules.pro. - Therefore, there are no Proguard keep rules anywhere in Sentry's libraries protecting the
io.sentry.okhttp.**package from optimization.
- The
- R8 Optimization Conflict: Since Sentry OkHttp classes are completely unprotected, R8 (under Full Mode) aggressively optimizes, obfuscates, and inlines them (e.g., companion objects and helpers) on top of the raw bytecode manually woven by the Sentry ASM visitor. This generates inconsistent local variables allocation and corrupt
StackMapTableframes in the final.dexfile. - JIT Compiler Crash: When ART's background JIT compiler thread (which is shared across Android 14+ via mainline system updates) attempts to compile this corrupt method into native ARM64 instructions, the strict verificator in ART fails to resolve the incorrect stack maps, resulting in a fatal native memory pointer disintegration (
SIGSEGV).
Temporary Workaround
Adding these rules to the application's proguard-rules.pro file completely resolves the issue, since it prevents R8 from inlining/optimizing the woven bridge:
# Prevent R8 from optimizing/inlining the unprotected Sentry OkHttp classes
-keep class io.sentry.okhttp.** { *; }
-dontwarn io.sentry.okhttp.**
# Protect internal RealCall bytecode manipulated by the plugin
-keep class okhttp3.internal.connection.RealCall { *; }
- 主要語言
- Kotlin
- 星號
- 1.4k
- 分支
- 478
- 平均合併
- 2 天 20 小時
- 30 天內合併 PR
- 71
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
getsentry/sentry-java 的其他 Issue
-
Improvement Java Platform: Android Platform: Java
難度 2/5 1-3 小時 新手友好度 75/100
getsentry/sentry-java#6145 · 1 則留言 · 已指派 1 人 ·
-
Bug Java Platform: Android Platform: Java
難度 2/5 1-3 小時 新手友好度 78/100
getsentry/sentry-java#6138 · 1 則留言 ·
-
Feature Java Platform: Java Spans
難度 2/5 1-3 小時 新手友好度 68/100
getsentry/sentry-java#5984 · 1 則留言 ·
-
Android Task Traces
難度 2/5 1-3 小時 新手友好度 68/100
getsentry/sentry-java#5376 · 1 則留言 ·
-
Android Docs Errors
難度 2/5 1-3 小時 新手友好度 64/100
getsentry/sentry-java#5375 · 1 則留言 ·
查看 getsentry/sentry-java 的全部 Issue
相似的 Issue
-
enhancement
難度 2/5 1-3 小時 新手友好度 75/100
Richie97/track-history#325 ·
-
bug CLI documentation reliability
難度 2/5 1-3 小時 新手友好度 70/100
-
KW-related Type:bug UI / UX
難度 2/5 1-3 小時 新手友好度 70/100
-
bug
難度 2/5 1-3 小時 新手友好度 75/100
RevenueCat/purchases-android#4299 · 1 則留言 ·
-
bug
難度 2/5 1-3 小時 新手友好度 75/100
AAswordman/Operit#1265 · 3 則留言 ·