1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# PDF writer allocation failures — tracker21 (2026-11-15)
## Scope
Source-only, uncommitted repair in `/tmp/signet-roadmap-20261112/integration`,
`feat/feature-first-roadmap`. Original dirty checkout and preserved previews
(:18087, :18090, :8080), unrelated services and production are untouched.
No dependencies, schema, installation, runtime configuration or ABI changes.
Aggregate resource/native acceptance20 and actual API logging22 remain open.
## Deterministic red → green
`sh test/pdfw-alloc.sh` compiles the actual `pdfw.c` and `ttf.c` with test-only
allocator substitution. A bounded pointer registry checks their allocations,
including loaded TTF bytes, glyph bookkeeping, strings and realloc ownership.
Libc/codec internals are NOT interposed. Separate child processes have a3s alarm
so persistent allocation failure cannot hang the suite indefinitely.
The healthy public-API path loads real DejaVuSans and synthetic PNG bytes, grows
page content multiple times, clips an image and writes two pages. It traverses
19 allocation positions in this fixture (not19 unique allocation call sites).
Every position is failed once and then persistently in
separate cases. Four additional targeted cases isolate open, existing-buffer
growth, font glyph bookkeeping and font path allocation. Assertions reject leaks,
crashes/timeouts and incorrect success for the targeted fatal writer errors.
Existing unusable-font fallback and caller-visible image failures are preserved.
Healthy output is independently checked by qpdf and pdfinfo (two pages).
Red invocation on the unchanged `signet-parser-final-r2` product source:
```
podman exec signet-pdfw-alloc-check sh /src/test/pdfw-alloc.sh
```
(The host uses `podman machine ssh` to avoid the known host known_hosts issue.)
Red log `/tmp/signet-pdfw-red.log`:17 failed cases, including growth/font leaks
and SIGALRM on persistent initial object-table allocation failure. A preliminary
wrong installed-font path was corrected before obtaining this reproduction.
The source audit's attribution of the spin to `cprintf()` was imprecise:
`cprintf()` returns after realloc failure but loses the old buffer and later
calls try allocating again. The deterministic infinite retry is the
`pdfw_open()` object-reservation loop, which ignored `new_obj()` failure.
Minimal repair:
- Content realloc uses a temporary pointer and updates capacity only on success;
an already failed writer does not format/reallocate more content. Negative
formatting results and capacity overflow fail rather than retrying forever.
Initial sizing uses a null buffer without undefined null-pointer arithmetic.
- Font bookkeeping failure frees all unpublished slot resources immediately.
- Open stops on object allocation failure, closes its file and frees ownership.
- Close skips finalisation once failure is known, always releases owned memory
and returns failure. Normal rendering/layout/font fitting is unchanged.
Green `/tmp/signet-pdfw-green.log`:19 points, transient/persistent failures,
**0 failed cases**, healthy two-page PDF passes. The retained test is run by
normal `test/e2e.sh` and its standalone `pdfw-alloc` mode.
## Fresh acceptance
Candidate image/container `signet-pdfw-final`, disposable loopback18104 during
verification. Original parser candidate remains unchanged.
- Clean image build executes `make clean`, `make -j2`, `make install`; no compiler
warnings. `/tmp/signet-pdfw-build.log`.
- Full `sh /src/test/e2e.sh` ends **all passed**, including the new allocation
test and retained image/command/identity/snapshot/signature/metadata/PIM/upload/
parser contracts. `/tmp/signet-pdfw-e2e.log`.
- Separate `sh /src/test/e2e.sh render-contract`: all pass, including failed
release, hung-command cleanup, queue retry, replay and database commit gates.
`/tmp/signet-pdfw-render.log`.
- Existing real Chrome signing flow passes against18104, using the preinstalled
external Playwright Core read-only (no package install or new automation JS).
`/tmp/signet-pdfw-browser.log`, screenshots `/tmp/signet-pdfw-browser/`.
Both-page edit/proof/stamped/final screenshots reviewed: matching text fitting,
circular seal and JPEG placement; facsimiles only appear after the appropriate
sign-offs. Audit page reviewed. Synthetic document
`30d37762-c1bb-4bc8-a6ac-bc66e5185332` only in this disposable stack.
- `sh -n test/pdfw-alloc.sh test/e2e.sh`, manual POSIX shell review and
`git diff --check` pass. Tests run with `sh`, not just syntax checked.
- Native source, UI, schema, configs, vendor and tests plus Makefile/Containerfile
SHA256 manifests exactly match the tested image:
`/tmp/signet-pdfw-{host,image}.sha256`. A separate final standalone allocation
rerun also passes: `/tmp/signet-pdfw-repeat.log`.
- Both owned containers stopped/retained after verification; preserved18087
still responds HTTP200. The service-bearing final stack stopped gracefully;
the native-test-only shell/sleep container needed Podman's SIGKILL fallback
after20s (no services or user state). `/tmp/signet-pdfw-stopped.log`.
Allocation injection is at the native writer seam, not an OOM experiment on the
live worker. Codec-internal allocation failure, other render inputs and a whole
system memory/RSS certificate are not established. Native/proxy/DAM/shared-service
and backup gates remain ticket14; no deployment is authorised by this result.
Private source/evidence backup (not runtime user-data backup):
`/Users/saikrupa/.local/var/signet-feature-backups/pdfw-allocation-20261115T013439Z`.
Before/after source, patches/status, source/image checksums and synthetic evidence
are retained privately. Only owned disposable21 containers are stopped/retained;
no preserved stack is upgraded. Old18087 PIM Resync remains unsafe (FLUSHDB).