Android: `HttpClient$FutureShim` JNI references are never released after requests complete, leading to a reference-table overflow abort
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 48/100
Rechercherichtung
Start in lib/http/HttpClient_Android.cpp and trace SendRequestAsync, dispatchCallback, CallbackForCancel, and CancelAllRequests, checking how JNI local and global references are released on completion and cancellation. Reproduce the reported reference growth with the heap dump steps in the issue, then verify completed, cancelled, and failed requests release their references.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
On Android, completed com.microsoft.applications.events.HttpClient$FutureShim objects (the FutureTask created by createTask) build up as JNI GC roots and are never released. Over a long session this approaches ART's 51,200-entry JNI reference limit and the process aborts with JNI ERROR (app bug): global reference table overflow in HttpClient_Android::SendRequestAsync.
Environment
- SDK: maesdk
3.10.40.1(a Teams-specific build based on this repo) - Device: Samsung SM-A146B, Android 15 (API 35)
Repro
- Run an app that sends 1DS telemetry over the default Android
HttpClient. - Force a GC, capture a heap dump, and count
HttpClient$FutureShiminstances. - Generate normal activity and let queued uploads finish.
- Force a GC and capture a second heap dump. Leave the app idle for 3 minutes and capture a third.
Expected: after completion, cancellation or failure, FutureShim instances become collectable and the count falls back toward baseline.
Actual: the count only goes up across heap dumps taken after a forced GC: 2,194 → 2,587 → 2,607.
- Every inspected instance is already complete:
FutureTask.state == 2, andcallable,runnerandwaitersare all null. - Representative instances are held directly by
ROOT_JNI_LOCALroots. - Crash evidence from the field shows about 50,257
FutureShimreferences at the time of the reference-table overflow abort.
Suspected cause (lib/http/HttpClient_Android.cpp)
SendRequestAsync:result = env->PopLocalFrame(result)hands back a new local reference in the caller's frame, and nothing ever callsDeleteLocalRefon it. These calls run on native threads that are attached and never detached, so local references are never freed automatically. That matches theROOT_JNI_LOCALroots we see.- The global reference:
m_java_request = env->NewGlobalRef(result)is released only in~HttpRequest(). Any path that removes the request fromm_requestswithout destroying theHttpRequestwould keep the global reference alive. Those paths aredispatchCallback→GetAndRemoveRequest,CallbackForCancelandCancelAllRequests. - Minor:
CallbackForCancelleaks the local reference returned byGetObjectClass.
Suggested fix
- Call
DeleteLocalRef(result)afterexecuteTaskand on the cancel path. - Release
m_java_requestwithDeleteGlobalRefas soon as the request reaches a final state (success, cancel, retry replacement, or error/early return), rather than relying on theHttpRequestdestructor. - Optionally wrap request sends in
PushLocalFrame/PopLocalFrameon persistently attached threads.
Workaround
None on the app side. The leaked references are owned by the SDK, and an app cannot safely release them.
- Vorherrschende Sprache
- C
- Sterne
- 104
- Forks
- 67
- Ø Merge
- 2 T. 12 Std.
- Gemergte PRs (30 T.)
- 8
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoft/cpp_client_telemetry
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
microsoft/cpp_client_telemetry#1550 ·
-
C API enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
-
OneDS C++ SDK retries already-ingested iOS events, causing duplicate telemetry recordsEvtl. vergeben @bmehta001 hat das vor 23 Tagen übernommen. Offenbug
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
microsoft/cpp_client_telemetry#1542 · 3 Kommentare · 1 zugewiesene Person ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
microsoft/cpp_client_telemetry#1504 ·
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
microsoft/cpp_client_telemetry#1413 · 2 Kommentare ·
Alle Issues in microsoft/cpp_client_telemetry
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 63/100
FriendsofECCE/ECCE#519 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 95/100
containers/crun#2415 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bluetooth: Controller: memcpy() with NULL source in HCI extended and periodic reportsEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
zephyrproject-rtos/zephyr#123423 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag