Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Android: `HttpClient$FutureShim` JNI references are never released after requests complete, leading to a reference-table overflow abort

Offen
#1,551 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
android, cpp
Bereich
backend, mobile

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
  1. Run an app that sends 1DS telemetry over the default Android HttpClient.
  2. Force a GC, capture a heap dump, and count HttpClient$FutureShim instances.
  3. Generate normal activity and let queued uploads finish.
  4. 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, and callable, runner and waiters are all null.
  • Representative instances are held directly by ROOT_JNI_LOCAL roots.
  • Crash evidence from the field shows about 50,257 FutureShim references 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 calls DeleteLocalRef on it. These calls run on native threads that are attached and never detached, so local references are never freed automatically. That matches the ROOT_JNI_LOCAL roots we see.
  • The global reference: m_java_request = env->NewGlobalRef(result) is released only in ~HttpRequest(). Any path that removes the request from m_requests without destroying the HttpRequest would keep the global reference alive. Those paths are dispatchCallback → GetAndRemoveRequest, CallbackForCancel and CancelAllRequests.
  • Minor: CallbackForCancel leaks the local reference returned by GetObjectClass.
Suggested fix
  • Call DeleteLocalRef(result) after executeTask and on the cancel path.
  • Release m_java_request with DeleteGlobalRef as soon as the request reaches a final state (success, cancel, retry replacement, or error/early return), rather than relying on the HttpRequest destructor.
  • Optionally wrap request sends in PushLocalFrame/PopLocalFrame on 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

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus microsoft/cpp_client_telemetry

Alle Issues in microsoft/cpp_client_telemetry

Ähnliche Issues

Weitere Issues zu C

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.