Skip to content

[release/9.0-staging] Fix double dispose of GCHandle in BrowserWebSocket #113541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Mar 14, 2025

Backport of #113464 to release/9.0-staging

/cc @pavelsavara @filipnavara

Customer Impact

  • Customer reported
  • Found internally

This impacts experimental branch of NativeAOT for WASM. We didn't experience the issues on Mono/browser yet, likely because it's more resilient to double free of the GCHandle.

Regression

  • Yes
  • No

#96618

Testing

Existing automated tests

Risk

Low

filipnavara and others added 2 commits March 14, 2025 16:18
MemoryHandle is a struct, so passing it into an IDisposable parameter creates a box. This causes two copies of GCHandle to exist which are no longer synchronized and can be double disposed.

This happened when passing pinBuffer into CancellationHelper in
ReceiveAsyncCore and SendAsyncCore. In both cases the caller does the Dispose itself inside a finally, so there's no need to pass the pinBuffer to CancellationHelper at all.
@ghost ghost added the area-System.Net label Mar 14, 2025
@pavelsavara pavelsavara self-assigned this Mar 14, 2025
@pavelsavara pavelsavara added arch-wasm WebAssembly architecture os-browser Browser variant of arch-wasm labels Mar 14, 2025
@pavelsavara pavelsavara added this to the 9.0.x milestone Mar 14, 2025
Copy link
Contributor

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

@pavelsavara
Copy link
Member

Maybe we don't need to backport it until we hear about somebody impacted on Mono ?

thoughts @lewing ?

@filipnavara
Copy link
Member

I'd prefer the backport to happen. The GC holes/double-frees are notoriously hard to analyze. Even if it crashes for someone it's difficult to trace back to the root cause.

@pavelsavara pavelsavara added the Servicing-consider Issue for next servicing release review label Mar 17, 2025
@pavelsavara pavelsavara added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Mar 18, 2025
@pavelsavara
Copy link
Member

/ba-g CI timeout

@pavelsavara pavelsavara merged commit 4d66ebb into release/9.0-staging Mar 18, 2025
96 of 104 checks passed
@jkotas jkotas deleted the backport/pr-113464-to-release/9.0-staging branch March 23, 2025 02:42
@github-actions github-actions bot locked and limited conversation to collaborators Apr 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-System.Net os-browser Browser variant of arch-wasm Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants