Skip to content

Keep a call racing with close() from using a freed PeerConnection (1.0.4-ip.2) - #4

Merged
jlftt merged 1 commit into
masterfrom
fix/close-race
Oct 4, 2026
Merged

jlftt merged 1 commit into
masterfrom
fix/close-race

Conversation

@jlftt

@jlftt jlftt commented Oct 4, 2026

Copy link
Copy Markdown
Owner

close() now really frees the native PeerConnection, so a call on another thread that read the handle just before (an ICE candidate arriving while the connection is dropped) could use freed memory and take the whole JVM down.

Every JNI call now takes its own reference under the Java object's monitor, and close() empties the handle under that monitor before dropping Java's reference. The monitor is only held to read the handle, never across a call into WebRTC.

Not compiled locally: the Build check on this pull request is the compile test.

🤖 Generated with Claude Code

…0.4-ip.2)

close() now releases the native PeerConnection, so a call on another thread that
read the handle just before could use it after it was freed: an ICE candidate
arriving while a connection is dropped, for example. Every call now takes its own
reference under the Java object's monitor, and close() empties the handle under
that same monitor before dropping Java's reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jlftt
jlftt merged commit 6f86a0a into master Oct 4, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants