mORMot2 DailyDaily read of upstream commits

PDF reliability sweep fixes FPC crashes, encryption and font output

The PDF engine receives fifteen focused fixes covering FPC Unicode crashes, encrypted strings, font subsets, image validation, document reuse and text layout. Two backend fixes also close failed shared transactions correctly and keep THttpAsyncServer uploads alive when clients send Expect: 100-continue. DuckDB's five-step Appender and type-cache cleanup is included again because its branch merged in this range.

TL;DR

  • FPC no longer dereferences a stale fUsedWide array after Unicode glyph registration reallocates it.
  • SharedTransaction now rolls back or releases its level when COMMIT fails, preventing later statements from inheriting an abandoned transaction.
  • THttpAsyncServer sends 100 Continue as an interim response and keeps the request body stream and connection alive.
  • PDF output fixes cover RC4 document reuse, UTF-16 encryption, TrueType checksums, CMaps, JPEG colour spaces and bidirectional text.
  • DuckDB's Appender batching and cached logical-type conversion land together in the merged branch.

Upgrade advice

Land on 7b9353c34f095d6f7ae7441fa6b6bdaa237a89e0, build 2.4.17677, which contains the PDF follow-ups and the merged HTTP, transaction and DuckDB branches. Prioritize this revision for FPC PDF generation, shared external-database transactions or async uploads above 1 MB. The raw payload records no superseded_by successor.

Commits29
Lines+3707 -957
Read6 min

23 of 23 entries · 29 commits upstream

Stories
# Entry Category Units
1 High Async HTTP uploads survive the 100 Continue interim response THttpAsyncServerConnection.DoHeaders sends HTTP_CONTINUE_RESPONSE immediately with RawWrite and queues only any unsent remainder. AfterWrite recognizes writes while the request is still between hrsGetBodyChunkedHexFirst and hrsWaitAsyncProcessing and returns soContinue without releasing request state. Fixes mormot.net.async 3f939de0+171-3

net: fixed THttpAsyncServer "Expect: 100-continue" closing the connection

Impact

Clients such as curl that add Expect: 100-continue to bodies above 1 MB can complete in-memory and OnBodyDownload uploads, including keep-alive and paoWritePollOnly cases, instead of seeing the connection close mid-body.

zen010101 · 11:22 UTC · view the commit on GitHub →

2 High FPC Unicode PDF rendering no longer uses a stale glyph array TPdfWrite.AddGlyphFromChar, TPdfFontTrueType.GetAndMarkGlyphAsUsed and GetWideCharWidth now call FindOrAddUsedWideChar before indexing fUsedWide. This avoids keeping an array address across a call that may reallocate the dynamic array. Fixes mormot.ui.pdf 52934bbd+127-5

ui: pdf - fUsedWide[] is indexed once FindOrAddUsedWideChar has grown it (an access violation on FPC)

Impact

On FPC, measuring or drawing the first character outside WinAnsi could raise an access violation. Delphi code follows the safer evaluation order too; application APIs do not change.

Sven Harazim · 07:59 UTC · view the commit on GitHub →

3 High Failed shared commits no longer leave a connection inside a transaction TSqlDBConnectionProperties.SharedTransaction calls ReleaseFailedCommit after a failed commit. It rolls back when its transaction is the only level, or decrements fTransactionCount when another owner remains. SQLite3 and Zeos StartTransaction also undo the counter when the database call fails. Fixes mormot.db.sql+2 ff3b6073+117-9

db: release the connection transaction when SharedTransaction() Commit fails

Impact

A deferred constraint failure or lost connection can no longer leave an unregistered database transaction open for later statements or trigger a misleading rollback-in-autocommit error at disconnect.

Dimitris Kounalakis · 10:06 UTC · view the commit on GitHub →

4 High NewDoc clears references to objects freed with the previous PDF TPdfDocument.NewDoc now nils fMetaData, fOutputIntents, fOutlineRoot, fEncryptionObject and the page, contents and page-font-list references held by fCanvas after FreeDoc destroys the old object graph. Fixes mormot.ui.pdf f1d7a62d+59-0

ui: pdf - NewDoc drops its references to the freed page, metadata, outlines and /Encrypt

Impact

Reusing a TPdfDocument no longer reads dangling page or trailer objects and can save a newly encrypted document reliably. Code that accesses Canvas.Page before AddPage still receives EPdfInvalidOperation.

Sven Harazim · 07:59 UTC · view the commit on GitHub →

5 High NewDoc renews RC4 state and closes abandoned direct saves TPdfDocument.FreeDoc now frees fSaveToStreamWriter when SaveToStreamDirectBegin was never ended. TPdfEncryptionRC4MD5.AttachDocument resets fLastObjectNumber so a new document cannot reuse an object key derived from the previous file ID. Fixes mormot.ui.pdf bedd4293+58-0

ui: pdf - NewDoc renews the RC4 object key and ends a direct save left open

Impact

A reused encrypted TPdfDocument applies the new file key even when object numbers repeat, and an abandoned direct save no longer makes the next save raise 'called twice'.

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

6 Medium DuckDB result types are parsed once per column mormot.db.raw.duckdb adds TDuckDBTypeInfo plus DuckDBTypeInfoInit and DuckDBTypeInfoDone. TSqlDBDuckDBStatement caches logical and nested types per result column. The public vector-to-text and vector-to-JSON helpers now take PDuckDBTypeInfo. Breaking changes mormot.db.raw.duckdb+1 0c5d1ac1+293-191

db: DuckDB logical types are now parsed once into a TDuckDBTypeInfo cache

Impact

Large and nested results avoid repeated logical-type C API calls and temporary strings. Code using only ISqlDBRows is unaffected; direct callers of the vector helpers need the new cache lifetime.

Migration required

For direct DuckDBVectorValueToJson, DuckDBVectorValueToText or DuckDBVectorValueToTextBuf calls, initialize TDuckDBTypeInfo, pass its address and release it with DuckDBTypeInfoDone.

tf · 05:55 UTC · view the commit on GitHub →

7 Medium DuckDB drops statement arrays in favor of Appender-backed ORM batches TSqlDBDuckDBConnectionProperties installs AppendBatchInsert as OnBatchInsert with a 4,096-row limit. Complete ordered create batches use TSqlDBDuckDBAppender; partial columns and conflict options fall back to MultipleValuesInsert. ExecutePrepared now rejects non-zero fParamsArrayCount. Breaking changes mormot.db.sql.duckdb 120ac439+141-136

db: DuckDB BindArray removed, OnBatchInsert now uses the Appender

Impact

ORM create batches use DuckDB's native bulk path. Direct Delphi or FPC code that binds arrays to a DuckDB statement still compiles but fails at ExecutePrepared after upgrading.

Migration required

Find DuckDB uses of BindArray, BindArrayCurrency and BindArrayDateTime; replace them with ORM batching, OnBatchInsert or ordinary parameters inside a transaction.

tf · 05:46 UTC · view the commit on GitHub →

8 Medium PDF images validate JPEG data and preserve grayscale colour space TPdfImage.Create inspects saved JPEG components before registering the stream, writes DeviceGray for one component and rejects four-component CMYK. CreateJpegDirect now raises EPdfInvalidValue for non-JPEG or CMYK input instead of leaving an incomplete image object. Fixes mormot.ui.pdf 2b37d153+168-32

ui: pdf - a JPEG gets the colour space of its data; CMYK and non-JPEG data raise

Impact

Grayscale JPEGs are described correctly in generated PDFs. Unsupported CMYK or invalid direct data now fails immediately, so callers that relied on silent incomplete objects will see an exception.

Worth a look

Check image-import paths for CMYK JPEGs and convert them to RGB before calling TPdfImage.

Sven Harazim · 07:59 UTC · view the commit on GitHub →

9 Medium Encrypted Unicode PDF strings now include the BOM in the cipher text TPdfWrite adds AddUnicodeHexString, which builds the FEFF BOM and UTF-16BE payload before applying document encryption. TPdfText and TPdfTextUtf8 use it, while AddUnicodeHex remains an unencrypted hexadecimal writer. Fixes mormot.ui.pdf 4170c8b3+83-17

ui: pdf - an encrypted Unicode text string has its BOM and UTF-16BE encrypted together

Impact

Encrypted PDF metadata containing non-WinAnsi text now follows ISO 32000 and can be decrypted as one complete string. Existing document-generation calls remain source-compatible.

Worth a look

Regenerate an encrypted PDF containing Unicode metadata and confirm it opens correctly in the readers you support.

Sven Harazim · 07:59 UTC · view the commit on GitHub →

10 Medium Uniscribe bidirectional runs ignore non-level state bits TPdfWrite.AddUnicodeHexTextUniScribe masks SCRIPT_STATE.uBidiLevel with $1f before passing embedding levels to ScriptLayout, excluding override and other state bits stored above the five level bits. Fixes mormot.ui.pdf cfc2797f+73-1

ui: pdf - Uniscribe gets the bidi level without the state bits above it

Impact

Windows PDF rendering with explicit bidi embeddings or overrides gets the intended visual run order. Delphi and FPC callers do not need to change text APIs.

Sven Harazim · 07:59 UTC · view the commit on GitHub →

11 Medium Zero-width combining marks keep their real text advance TPdfFontTrueType adds WideCharMissing to distinguish a missing glyph from a valid glyph whose advance is zero. TPdfCanvas.UnicodeTextWidth only consults the fallback font or DEFAULT_PDF_WIDTH when the glyph is actually absent. Fixes mormot.ui.pdf 2868a44f+57-6

ui: pdf - a glyph whose advance is 0 (a combining mark) is measured as 0, not as a missing one

Impact

Text containing combining accents is measured without an artificial character width, improving placement and line calculations. Existing public drawing calls remain compatible.

Sven Harazim · 07:59 UTC · view the commit on GitHub →

12 Medium PDF/A Unicode maps are split into specification-sized blocks TPdfFontTrueType.PrepareForSaving now emits at most 99 WinAnsi entries in each beginbfchar section of the PDF/A ToUnicode CMap, closing and reopening blocks until all mappings are written. Fixes mormot.ui.pdf 595dbca1+59-3

ui: pdf - the WinAnsi /ToUnicode CMap of PDF/A writes at most 99 entries per bfchar block

Impact

PDF/A files using many WinAnsi characters no longer produce an oversized bfchar block that strict validators or readers may reject. Application code is unchanged.

Worth a look

Revalidate representative PDF/A output with your normal conformance checker.

Sven Harazim · 07:59 UTC · view the commit on GitHub →

13 Medium Embedded TrueType subsets now carry the correct checksum ReduceTTF now byte-swaps each 32-bit table-directory word before adding it to the font checksum, matching the big-endian TrueType file representation used to derive head.checkSumAdjustment. Fixes mormot.ui.pdf 5368dcc8+57-1

ui: pdf - the reduced TrueType subset sums its table directory as big-endian words

Impact

Reduced embedded fonts now sum to the TrueType-required value and are less likely to be rejected or repaired by strict consumers. Application code does not change.

Sven Harazim · 07:59 UTC · view the commit on GitHub →

14 Medium Raster font resolution cache is shared and keyed correctly The previous raster-font name, index and fixed-width flag move from TPdfCanvas to TPdfDocument. AddTrueTypeFont and SetFontFallBackName invalidate the shared cache, and SetFont includes AIsFixedWidth in its cache key. Fixes mormot.ui.pdf a61d994b+45-10

ui: pdf - the raster font cache is shared by the canvases of a document, and follows its keys

Impact

Page and form canvases no longer retain moved font indexes or reuse a proportional fallback for fixed-width text after font-list or fallback changes. No source migration is needed.

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

15 Medium Adding a TrueType font preserves cached and existing font indexes TPdfDocument.AddTrueTypeFont now records the fallback name, resorts fTrueTypeFonts, recomputes moved indexes, clears the raster-name cache and increments existing TPdfFont indexes located after the insertion point. Fixes mormot.ui.pdf e4caf68f+52-0

ui: pdf - AddTrueTypeFont keeps the name cache, the fallback index and the created fonts' indexes

Impact

Documents that add fonts after selecting or resolving other fonts keep the intended fallback and reuse the correct TPdfFont objects. No caller migration is required.

Sven Harazim · 07:59 UTC · view the commit on GitHub →

16 Medium Invalid early PDF outlines no longer corrupt document cleanup TPdfOutlineEntry.Create now rejects a positioned outline before registering itself when no page exists. AddChild creates the entry before incrementing parent counts, so a constructor exception leaves neither a double-owned object nor stale counts. Fixes mormot.ui.pdf 9248feee+47-3

ui: pdf - an outline entry with a position before the first page is no longer freed twice

Impact

Calling CreateOutline with a position before the first page still raises EPdfInvalidOperation, but freeing the document no longer risks a second free and later valid outline counts remain correct.

Sven Harazim · 07:59 UTC · view the commit on GitHub →

17 Medium DuckDB Appender resolves schema-qualified ORM table names TSqlDBDuckDBAppender.Create splits a schema-qualified aTable when aSchema is empty and passes schema and bare table name separately to duckdb_appender_create. Tests now cover the ORM form main.arr. Fixes mormot.db.sql.duckdb 1d9eae84+17-4

db: DuckDB Appender accepts a schema-qualified table name

Impact

Appender-backed ORM batches work with default main.TableName names instead of looking for a literal table containing a dot. The fix precedes the final merge.

tf · 06:50 UTC · view the commit on GitHub →

18 Low PDF literal strings now use the standard backspace escape TPdfWrite.AddEscape now serializes byte 8 as \b instead of the non-standard \B. The regression test verifies the Subject entry in an uncompressed PDF dictionary. Fixes mormot.ui.pdf 77537f0a+21-1

ui: pdf - a backspace in a string is written \b, not \B

Impact

PDF readers can decode backspace characters correctly instead of treating the uppercase B as literal text. No Delphi or FPC source change is required.

Sven Harazim · 07:59 UTC · view the commit on GitHub →

19 Low PDF wrapper and viewer-preference getters return stored values TPdfDictionaryWrapper.GetHasData now tests fData for non-nil, and TPdfCatalog.GetNonFullScreenPageMode reads NonFullScreenPageMode from ViewerPreferences, matching the setter's storage location. Fixes mormot.ui.pdf 823a8296+18-2

ui: pdf - TPdfDictionaryWrapper.HasData and TPdfCatalog.NonFullScreenPageMode read what is written

Impact

HasData and NonFullScreenPageMode no longer report the inverse or default after values are present. Existing property use needs no source change but may observe corrected results.

Sven Harazim · 07:59 UTC · view the commit on GitHub →

20 Low TrueType faces without an English PostScript name get a valid fallback TPdfDocument.TtfFontPostcriptName initializes its result with TrueTypeFontName before searching the font name table. If no English platform 3, encoding 1 PostScript record is found, the family-derived name is retained. Fixes mormot.ui.pdf 75a2eed7+2-3

ui: pdf - the PostScript name of a face without an English one is the family name

Impact

Embedded fonts lacking that English name record no longer leave the PDF font name empty. Existing Delphi and FPC calls are unaffected.

Sven Harazim · 07:59 UTC · view the commit on GitHub →

21 Low Numeric column readers share one DuckDB integer set mormot.db.sql.duckdb introduces the internal DUCKDB_INT_TYPES set and reuses it in TSqlDBDuckDBStatement.ColumnDouble and ColumnCurrency instead of maintaining duplicate type branches. Under the hood mormot.db.sql.duckdb 78780e65+13-10

db: DuckDB integer type list shared by ColumnDouble and ColumnCurrency

Impact

There is no intended change to Delphi or FPC application code or returned numeric values. The two conversion methods now stay aligned as integer support evolves.

tf · 05:57 UTC · view the commit on GitHub →

22 Low DuckDB gets a named SQL dialect alias mormot.db.raw.duckdb exports dDuckDB as an alias of dPostgreSQL, and the provider assigns it to fDbms. TSqlDBDuckDBAppender.Create uses SplitRight instead of manual string splitting. Under the hood mormot.db.raw.duckdb+1 288e3cbf+10-11

db: DuckDB uses SplitRight() and a dDuckDB = dPostgreSQL constant

Impact

DuckDB keeps PostgreSQL-like SQL generation and the same schema parsing. The alias provides a stable provider-specific symbol; no application change is required.

tf · 09:05 UTC · view the commit on GitHub →

23 Low Expected commit failures no longer pollute the regression-test log TTestExternalDatabase.SharedTransactionCommitFailure is rearranged so expected COMMIT exceptions are exercised without normal exception logging. Production units are not changed by this commit. Tests 1b585fcd+35-29

test: no exception logging for the expected COMMIT failures

Impact

There is no impact on Delphi or FPC application code. Test output is quieter while retaining coverage of commit-failure cleanup.

Dimitris Kounalakis · 17:28 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