mORMot2 DailyDaily read of upstream commits

Windows socket shutdowns stop touching reused handles

This edition fixes a high-risk Windows socket shutdown race, two tunnel concurrency and payload-limit problems, HTTP request-state initialization, Windows file-version decoding, and PDF clipping of empty EMF regions. Two public contracts need attention: custom INetTls implementations gain SocketClosed, and THttpRequestContext.ProcessInit is replaced by ResetZero.

TL;DR

  • TCrtSocket.Abort and Close now coordinate on Windows so TLS teardown cannot use a closed SOCKET value that the OS has already reassigned.
  • Tunnel handshake draining is serialized to remove a potential deadlock, while OpenDirect payloads may now reach 16 MB; threaded TCP frames remain capped at 64 KB.
  • THttpRequestContext.ProcessInit is replaced by ResetZero, and THttpServerSocket.Create now initializes the new -1 sentinels.
  • Windows file-version strings are decoded within their resource-entry length and without a trailing terminator.
  • Empty EMF clip regions now emit a zero-area PDF path so following graphics stay clipped.

Upgrade advice

Land on the edition head e1158d2b7c9eab28a7b565f44812fec0d41e3679 (2.4.17982). Rebuild Delphi and FPC targets, add SocketClosed to any custom INetTls implementation, replace direct ProcessInit calls with ResetZero plus the appropriate State assignment, and stress Windows server shutdown, tunnel handshakes and OpenDirect large payloads.

Build2.4.17963 → 2.4.17982
Commits17
Lines+890 -194
Read4 min

14 of 14 entries · 17 commits upstream

Stories
# Entry Category Units
1 High HTTP request reset no longer chooses a state machine THttpRequestContext.ProcessInit is removed and replaced by ResetZero, which only sets RangeLength and ContentLength to -1. Async client and server callers now assign hrsConnect or hrsGetCommand explicitly after resetting. Breaking changes mormot.net.async 128e2886+16-16

net: defined ResetZero to replace ProcessInit for HTTP state machine

Impact

Delphi/FPC code that directly calls ProcessInit will fail to compile. Replacement code must call ResetZero and set State to the correct client, server or custom state; framework-owned paths are updated in this edition.

Migration required

Search for THttpRequestContext.ProcessInit, replace each call with ResetZero, and assign State explicitly before processing input.

Public API

  • THttpRequestContext.ProcessInitremoved — Removed; callers must use ResetZero and select State themselves.
  • THttpRequestContext.ResetZeroadded — Initializes RangeLength and ContentLength to -1 without changing State.

Arnaud Bouchez · 09:08 UTC · view the commit on GitHub →

2 High Windows abort and TLS shutdown no longer reuse a closed SOCKET TCrtSocket.Abort marks that Windows already called closesocket; Close then skips a second close and calls the new INetTls.SocketClosed hook. SChannel clears its socket and OpenSSL disables SSL_shutdown so neither sends close_notify through a stale, possibly reassigned handle. Fixes mormot.net.sock+2 38231157+248-2

net: TCrtSocket.Close won't reuse a socket handle closed by Abort on Windows

Impact

Stopping a Windows HTTP server with idle keep-alive TLS connections no longer risks WSAENOTSOCK or closing an unrelated connection after rapid SOCKET-value reuse. Delphi and FPC Windows backends benefit; custom INetTls implementations must add the new method.

Migration required

Upgrade Windows network servers. If you implement INetTls, add SocketClosed and make it suppress every later access to the OS socket; then test aborting blocked receives and TLS server shutdown.

Public API

  • INetTls.SocketClosedadded — Implementations must stop using the OS socket after this notification.
  • TNetTlsContext.SocketClosedadded — Forwards the already-closed notification to the active TLS implementation.

Sven Harazim · 06:02 UTC · view the commit on GitHub →

3 High Tunnel handshake draining no longer races socket workers TTunnelLocal serializes handshake inspection under fSafe, lets TTunnelLocalThread drain queued frames after its handshake, and avoids a second OpenInternal drain for socket-bound workers. This removes competing drain paths. Fixes mormot.net.tunnel 7f646e33+15-9

net: fixed Tunnel potential deadlock when draining frames

Impact

Tunnel connections that buffer frames during handshake no longer risk a lock-order deadlock. The fix applies to Delphi and FPC tunnel servers and clients; public method signatures are unchanged.

Arnaud Bouchez · 16:22 UTC · view the commit on GitHub →

4 Medium Empty EMF regions now clip all following PDF content TPdfEnum.ExtSelectClipRgn represents an empty EMF region as one zero-size PdfBox. PDF output now emits a real zero-area rectangle before the clip operator instead of a clip operator with no path. Fixes mormot.ui.pdf ae4f9372+78-0

ui: pdf - an empty EMF clip region clips everything, with a valid path

Impact

PDFs generated from EMF input no longer leave bitmaps or text visible after an empty SelectClipRgn. Delphi and FPC PDF users get corrected rendering without source changes; the commit notes an unrelated existing FPC 3.2.2 Win32 test failure.

Worth a look

Regenerate representative EMF-based PDFs and compare empty or disjoint clip regions in the viewers you support.

Sven Harazim · 04:20 UTC · view the commit on GitHub →

5 Medium HTTP server sockets initialize request sentinels at construction THttpServerSocket.Create now calls Http.ResetZero after constructing the socket. RangeLength and ContentLength therefore start at -1 while State remains hrsNoStateMachine until the owning server selects a processing path. Fixes mormot.net.server 1aeaa636+3-2

net: fixed THttpServerSocket.Create

Impact

Fresh Delphi/FPC HTTP server sockets no longer carry zero values where the request parser expects -1 sentinels. No source migration is needed unless application code inspects an unprocessed socket context.

Arnaud Bouchez · 09:09 UTC · view the commit on GitHub →

6 Medium Windows file-version reads stay inside each resource entry The Windows version-resource path replaces a NUL-terminated Win32PWideCharToUtf8 read with Unicode_ToUtf8 using the length returned by VerQueryValue. A later same-day commit removes the included final terminator. Fixes mormot.core.os 4c535155+1-1

Fileversion reads behind end of an entry

Impact

Malformed or tightly packed version resources no longer let conversion scan behind the selected entry. Delphi and FPC Windows backends should take the edition head so the terminator follow-up is included.

Worth a look

Take this together with f957274521da5e82107d6384e0407bb14162e164 and test FileVersion on the application binaries you ship.

TK-OPC · 13:34 UTC · view the commit on GitHub →

7 Medium Direct tunnels accept payloads up to 16 MB mormot.net.tunnel splits frame limits by mode: OpenDirect application data may reach 16 MB plus authentication overhead, while handshake frames keep the 72 KB cap and threaded TCP application data remains limited to 64 KB. New features mormot.net.tunnel 74cfe56d+32-24

net: allow 16MB JPEG/KVM payload after TTunnelLocal.OpenDirect

Impact

Delphi/FPC applications using OpenDirect can send larger JPEG, KVM or other binary messages without chunking up to the new limit. TCP forwarding behavior does not change; oversized direct messages above 16 MB are still rejected.

Worth a look

Exercise boundary sizes around 64 KB and 16 MB in OpenDirect integrations, and keep chunking for threaded TCP mode.

Public API

  • TTunnelLocal.SendDatabehaviour-changed — Accepts application payloads up to 16 MB in direct mode; TCP mode remains capped at 64 KB.

Arnaud Bouchez · 10:39 UTC · view the commit on GitHub →

8 Low File-version decoding drops the resource terminator The Windows file-version reader treats the reported size as WideChar units including a possible final #0, subtracts that terminator, then passes the bounded length to Unicode_ToUtf8. Fixes mormot.core.os f9572745+6-1

sz is in WideChars and includes the #0 terminator, if any

Impact

Delphi and FPC Windows callers receive the same version text without an embedded trailing NUL. No API or build change is required.

TK-OPC · 15:37 UTC · view the commit on GitHub →

9 Low i386 SynLZ decompression removes one branch The i386 assembly decompressor replaces a compare-and-branch cap with a CMOVA instruction when limiting the copy length. No data format or Pascal declaration changes. Performance mormot.core.compress f3ebf1bf+17-18

core: minor SynLZ decompression optimization on i386 asm

Impact

Only 32-bit x86 SynLZ decompression may become marginally faster. Delphi/FPC applications need no source change, and other architectures are unaffected.

Arnaud Bouchez · 18:06 UTC · view the commit on GitHub →

10 Low WebSocket broadcast tests wait for slow connection registration The WebSocket broadcast regression test records the connected handle and waits up to five seconds for ConnectionFind to see it before broadcasting. This closes a test race observed on slow Raspberry Pi systems. Tests c1ea434d+14-2

tests: fixed WS broadcast logic on slow RPi (LUTI)

Impact

Production WebSocket behavior and public APIs do not change. CI and local Delphi/FPC test runs on slower hardware should become less flaky.

Arnaud Bouchez · 08:06 UTC · view the commit on GitHub →

11 Low SSSE3 numeric tests now check the right CPU feature test.core.base changes the guard for SSSE3 numeric routines from cfSSE3 to cfSSSE3. The accompanying tunnel edits are comments and shutdown-order clarification only. Tests mormot.net.tunnel e1158d2b+7-8

tests: fixed SSE3/SSSE3 confusion

Impact

Application code is unchanged. Test runs no longer invoke SSSE3-only instructions on CPUs that expose SSE3 but not SSSE3; Delphi and FPC runtime paths are unaffected.

Arnaud Bouchez · 18:07 UTC · view the commit on GitHub →

12 Low PDF empty-clip failures now report formatted context TTestUiPdf.EmfEmptyClip replaces Check plus a preformatted string with CheckUtf8 and its format arguments. Test conditions and production PDF code are unchanged. Tests fc00e4c8+5-5

tests: EmfEmptyClip reports through CheckUtf8()

Impact

Only diagnostic output from the test suite changes. Delphi/FPC application behavior is unaffected.

Sven Harazim · 08:43 UTC · view the commit on GitHub →

13 Low Tunnel documentation now describes direct endpoints and ownership The security guide and Pascal comments are reorganized around OpenDirect, SendData, TTunnelSocketTransmit ownership, plaintext-versus-relay frames, and the lifetime of the TCP worker and cryptographic state. Executable statements are unchanged. Docs mormot.net.tunnel a668f1d2+115-102

net: fixed Tunnel documentation after OpenDirect() introduction

Impact

There is no runtime or source impact for Delphi/FPC applications. Maintainers of custom ITunnelTransmit adapters gain clearer ownership and frame-format guidance.

Arnaud Bouchez · 08:53 UTC · view the commit on GitHub →

14 Low File-version result casing is normalized A local result identifier in the Windows file-version code changes from res to Res. Pascal is case-insensitive, so emitted code and behavior remain identical. Housekeeping mormot.core.os b60e0a8c+1-1

Uppercase writing correction

Impact

There is no application impact for Delphi or FPC and no action is needed.

TK-OPC · 13:37 UTC · view the commit on GitHub →

Upstream activity commits per day · last 60 days
Commits1007
Active days49/60
Busiest2026-09-30
Peak60
2026-09-30: 60 commits2026-10-01: 26 commits2026-10-02: 30 commits2026-10-03: 32 commits2026-10-04: 15 commits2026-10-05: 1 commit2026-10-06: 26 commits2026-10-07: 37 commits2026-10-08: 27 commits2026-10-09: 35 commits2026-10-10: 12 commits2026-10-11: 2 commits2026-10-12: 40 commits2026-10-13: 31 commits2026-10-14: 23 commits2026-10-15: 16 commits2026-10-16: 27 commits2026-10-17: 0 commits2026-10-18: 0 commits2026-10-19: 0 commits2026-10-20: 0 commits2026-10-21: 0 commits2026-10-22: 3 commits2026-10-23: 6 commits2026-10-24: 29 commits2026-10-25: 7 commits2026-10-26: 25 commits2026-10-27: 4 commits2026-10-28: 8 commits2026-10-29: 17 commits2026-10-30: 20 commits2026-10-31: 0 commits2026-11-01: 0 commits2026-11-02: 16 commits2026-11-03: 32 commits2026-11-04: 15 commits2026-11-05: 32 commits2026-11-06: 26 commits2026-11-07: 19 commits2026-11-08: 2 commits2026-11-09: 29 commits2026-11-10: 17 commits2026-11-11: 8 commits2026-11-12: 38 commits2026-11-13: 39 commits2026-11-14: 9 commits2026-11-15: 6 commits2026-11-16: 21 commits2026-11-17: 30 commits2026-11-18: 37 commits2026-11-19: 28 commits2026-11-20: 31 commits2026-11-21: 0 commits2026-11-22: 0 commits2026-11-23: 1 commit2026-11-24: 6 commits2026-11-25: 3 commits2026-11-26: 3 commits2026-11-27: 0 commits2026-11-28: 0 commits
2026-09-302026-11-28