Summary
In Xamarin.Android.Tools.Aidl.CSharpCodeGenerator-generated Proxy code for non-oneway void methods, the __reply Parcel is obtained and used (for ReadException ()) but is never recycled:
var __reply = Parcel.Obtain ();
try {
// ... write args, Transact (), __reply.ReadException ()
} finally {
__data.Recycle ();
// __reply.Recycle () is missing
}
This leaks Parcel instances on every cross-process call.
Fix direction
For non-oneway void methods the generator should either:
- Recycle
__reply in the finally block alongside __data, or
- Skip allocating
__reply entirely if no return value / out-parameter requires it (but still call Transact with a reply parcel so ReadException () can surface remote exceptions, then recycle it).
Where
src/Xamarin.Android.Tools.Aidl/CSharpCodeGenerator.cs — Proxy method emission.
Repro / evidence
See the golden output in tests/Xamarin.Android.Tools.Aidl-Tests/TestData/IBinderTypes.txt (added in #11460); the void Proxy method allocates __reply but the finally only recycles __data.
Notes
Summary
In
Xamarin.Android.Tools.Aidl.CSharpCodeGenerator-generated Proxy code for non-onewayvoidmethods, the__replyParcelis obtained and used (forReadException ()) but is never recycled:This leaks
Parcelinstances on every cross-process call.Fix direction
For non-
onewayvoid methods the generator should either:__replyin thefinallyblock alongside__data, or__replyentirely if no return value / out-parameter requires it (but still callTransactwith a reply parcel soReadException ()can surface remote exceptions, then recycle it).Where
src/Xamarin.Android.Tools.Aidl/CSharpCodeGenerator.cs— Proxy method emission.Repro / evidence
See the golden output in
tests/Xamarin.Android.Tools.Aidl-Tests/TestData/IBinderTypes.txt(added in #11460); the void Proxy method allocates__replybut thefinallyonly recycles__data.Notes
__replyrecycling for typed return values (those should also be audited).