Skip to content

AIDL CSharpCodeGenerator: generated Proxy void methods leak __reply Parcel #11508

@jonathanpeppers

Description

@jonathanpeppers

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions