Repository navigation
small fixes: hash's MSVC ARM64 C4324 and constinit canaries; webrtc's native races and cleanup hang (libdatachannel patches) - #56
Merged
Conversation
added 6 commits
November 23, 2026 17:06
… for two races of 0.24.6 that failed a native connection about once in 300 runs under load webcpp::webrtc's native test failed once on MSVC 14.3 (a_full_exchange: no channel, the state never connected). Under load on macOS the native tests failed 6 of 2100 runs, each an exchange whose connection went to failed, and libdatachannel's log named two races of the offerer, whose ICE transport starts while rtcSetRemoteDescription applies the answer: - DtlsTransport::start() registered its incoming callback, which replays the records the ICE transport kept, before setting the DTLS MTU; doRecv could answer the peer's ClientHello first, and OpenSSL, with SSL_OP_NO_QUERY_MTU and no MTU, failed the write (SSL_ERROR_SYSCALL, "Handshake failed: fatal I/O error"). dtls-mtu-before-incoming.patch sets the MTU first. - initSctpTransport() checked and created without a lock, so the DTLS Connected callback and processRemoteDescription() each made an SCTP transport, and the replaced one, destroyed, stopped DTLS. sctp-init-once.patch gives it a mutex, as initDtlsTransport() has. build.py applies tools/libdatachannel/patches/*.patch, by name, to the verified staged copy alone (the checkout and the archive stay upstream's), refuses one that touches anything but src/, one the sources hold already and one that no longer applies; the patches are inputs of the configuration's key. With both, 12000 runs under the same load failed none. Each patch is under libdatachannel's MPL-2.0. The guidelines' "unmodified" decision (D16) is amended pending the owner's approval.
…d constinit fixes and of webrtc's libdatachannel notes (eed3aab, fc1f57a)
…rsctp's iterator thread, for a native test that hung about once in 3000 runs on MSVC webcpp::webrtc's native test makes and destroys a runtime per test. On MSVC 14.5 x64 it hung about once in 3000 to 4000 runs, without the earlier patches too. The dumps showed the main thread in rtcPreload() waiting for libdatachannel's initialization lock, and the cleanup thread holding that lock in SctpTransport::Cleanup(), which calls usrsctp_finish() until it succeeds while usrsctp holds one endpoint it never frees: - usrsctp keeps its iterator thread's MUST_EXIT and EXITED flags across usrsctp_finish() and usrsctp_init(), so after the first cleanup each new iterator thread exits at once, and an iterator queued afterwards (the address work queue) holds its endpoint forever. The dumps showed the flags at 3, no iterator thread and an iterator holding that endpoint; a small program over the pinned libusrsctp.a reads the flags at 3 after a second usrsctp_init(), and at 0 with usrsctp-iterator-restart.patch, which clears them when the thread starts. - With that fixed, an association whose free began on the SHUTDOWN-ACK path was still left, in one run of about 9600, with no timer and no reference to free it (the dumps show states no single path reaches; upstream is told, with no fix). sctp-cleanup-bounded.patch bounds the SCTP cleanup to five seconds, within rtcCleanup()'s ten: usrsctp then stays initialized for the next initialization, which uses it, and the endpoint leaks instead of the process hanging. build.py lets a patch change the pinned usrsctp's sources (deps/usrsctp/usrsctplib/) besides libdatachannel's src/; each patch is under the licence of the files it changes.
… usrsctp corrections (local, for the lanes)
…p and usrsctp corrections and the native test's guarded checks (d8bcf37)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three small fixes, with the libdatachannel corrections that the third one needed.
CRYPTO_ALIGNstates force trailing padding, and MSVC for ARM64 (but not x64) reports that padding under /W4 /WX; a probe on 14.3 and 14.5 showed identical layouts on both architectures. The backends' canaries are declaredconstinitinstead of carrying NOLINT. Verified: native clang, gcc and Emscripten lanes; MSVC 14.3 and 14.5 ARM64 (743 passed each, hash plus crypto tests).native.run(a_full_exchange).tools/libdatachannel/build.pyappliestools/libdatachannel/patchesto its verified staged copy:dtls-mtu-before-incoming.patch: the DTLS server answered a ClientHello kept from before start() while its MTU was unset, and the handshake failed. Upstream fixed this on master in 0bdce84 (2026-11-19); the patch goes away once a release with it is pinned.sctp-init-once.patch: two threads each created an SCTP transport, and the replaced one stopped DTLS. Upstream master has no fix.usrsctp-iterator-restart.patch(a usrsctp bug, with a deterministic reproducer): after usrsctp_finish() and usrsctp_init(), the iterator thread exited at once, and a queued iterator held its endpoint forever.sctp-cleanup-bounded.patch(a mitigation): an association that usrsctp leaves with no timer and no reference (mechanism not identified, reported upstream) is leaked after 5 s instead of hanging the process. The owner's decision on shipping this mitigation is pending: do not merge before it.Verification on this tree (f3ac5ff): native webrtc lanes on clang, gcc and Emscripten; macOS lint clean; full Linux lint CLEAN; MSVC webrtc 14.3 and 14.5 x64 (36 passed each); 14.5 repeat runs (see HANDBACK). The guidelines' D16 ("libdatachannel unmodified") is amended, pending the owner's approval.