Skip to content

Fix SafeHandle usage in System.IO.Compression #89445

Open
@CarnaViire

Description

@CarnaViire

Discovered while fixing #86960. System.IO.Compression doesn't seem to utilize SafeHandle properly to have ref counts working during interop. See Stephen's comment below

I took a peek. I'm a little disheartened, not by your change, but by how SafeHandle is being used today in System.IO.Compression. It's not really being used how it's intended to be used. It's not storing a pointer to the data that's actually being used by the native code, so the SafeHandle isn't itself being passed through the LibraryImports, which means it's not being ref counted via DangerousAdd/Release the way it's meant to be as part of P/Invokes. As such, using DangerousAdd/Release here isn't necessarily achieving the goal.

We might want to revert "temporarily" to your previous workaround, and then separately overhaul how SafeHandle is used by all of this code.

Originally posted by @stephentoub in #87966 (comment)

After this issue is addressed, WebSockets should be updated to leverage DangerousAdd/Release

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions