Android: `HttpClient$FutureShim` JNI references are never released after requests complete, leading to a reference-table overflow abort
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 48/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- C
- Estrelas
- 104
- Forks
- 67
- Merge médio
- 2d 12h
- PRs com merge (30d)
- 8
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de microsoft/cpp_client_telemetry
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
microsoft/cpp_client_telemetry#1550 ·
-
C API enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
-
OneDS C++ SDK retries already-ingested iOS events, causing duplicate telemetry recordsTalvez já em andamento @bmehta001 assumiu há 27 dias. Abertabug
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
microsoft/cpp_client_telemetry#1542 · 3 comentários · 1 responsável ·
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
microsoft/cpp_client_telemetry#1504 ·
-
Dropping of telemetry eventsAbertabug
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
microsoft/cpp_client_telemetry#1413 · 2 comentários ·
Todas as issues de microsoft/cpp_client_telemetry
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Mantenedores costumam responder em até 2 dias
-
Component - Build
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 68/100
JustAResearcher/gpu-unlock-ada#110 ·
Mantenedores costumam responder em até 1 dia