Skip to content

test: name the descriptor kinds a leak assert found - #53

Closed
andypost wants to merge 394 commits into
masterfrom
test/fd-leak-attribution
Closed

andypost wants to merge 394 commits into
masterfrom
test/fd-leak-attribution

Conversation

@andypost

@andypost andypost commented Oct 8, 2026

Copy link
Copy Markdown
Owner

What

When a descriptor-leak assert fails, it now names which kinds of descriptor appeared since the baseline, not just that the count went up.

descriptors leak router: +1 fds, unix +1

Kinds are read from /proc/<pid>/fd readlinks: pipe, memfd, anon_inode name (eventfd, signalfd, eventpoll, io_uring), file path, and for sockets the protocol found by inode in /proc/<pid>/net/{tcp,tcp6,udp,udp6,netlink,unix} — tcp listen, tcp close-wait, udp6, netlink, unix, unix:<path>. Kernel autobind names are folded into unix:@autobind.

Why

The Alpine aarch64 build runs with --fds-threshold=160 and upstream nginx#1129 is still open because nobody could tell which descriptors they were. This turns the threshold back into a real assertion.

What didn't change

Counting, threshold, skip/restart paths, and the per-test re-baseline are all untouched. The kinds are read-only observation. Without /proc the message says so.

Review

One dsh headless review (DeepSeek Flash) found two real bugs, fixed in the second commit:

  • UnicodeDecodeError from read_text on /proc/net/unix crashed teardown when a socket path had non-UTF-8 bytes.
  • Unix socket paths with spaces were truncated by line.split().

Verification

  • Probe test that lowers the router baseline → exact kinds named, next test clean.
  • Live-process check names memfd/eventfd/pipe/socket/path.
  • Real unitd snapshot: every socket in router/controller/main resolved.
  • test_static, test_static_chroot, test_status, test_configuration, test_settings — same pass/fail with and without the change (failures are from a stale borrowed binary, not this change).

🤖 Generated with Claude Code

andypost and others added 30 commits September 13, 2026 19:34
The control API speaks HTTP/1.1 only.  The controller writes "HTTP/1.1 "
into every response line (src/nxt_controller.c:2850).  The HTTP/2 code we
linked in could never run.

It still cost us something.  It pulled in h2 and fnv, and h2 0.4.15
carries RUSTSEC-2026-0258.  Removing the feature closes that advisory
with no version upgrade.

Every "http2" here was ours and explicit, so this is a plain removal.
hyper-rustls does not enable HTTP/2 in its default features.  The crypto
provider does not come from its feature list either: unit-client-rs
depends on rustls directly with default features, and that is what
selects aws_lc_rs.  aws-lc-sys is still in the graph after this change
and ring is still absent.

One code change was needed.  enable_all_versions() is behind the http2
feature, and it also offered "h2" in the ALPN list.  enable_http1()
replaces it.

175 crates before, 173 after.  Tests and clippy warnings are unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Nobody was checking the lock file.  Two advisories were live in it when
this job was written, and neither had been noticed.

The job reads Cargo.lock only.  It needs no openapi generation and no
build, so it is fast and does not depend on the other jobs.

cargo-audit comes from taiki-e/install-action as a prebuilt binary.
That is the pattern the repo already uses for cross and for
cargo-component.

Two details decide whether this gate works at all.

It runs with --deny warnings.  A bare "cargo audit" exits 0 on an
unmaintained crate, so the job would report success while an advisory
was open.

It also runs on a weekly schedule.  The other triggers are a push and a
path-gated pull request, so a new advisory published against a lock file
nobody has touched would never start the job.  The test and build jobs
are excluded from that trigger, because the weekly run is for the audit
alone.

This comes after the HTTP/2 removal on purpose.  Added before it, the
job would fail on RUSTSEC-2026-0258, which that commit closes.  A gate
that is red on the day it lands gets ignored or switched off.

With --deny warnings the job is still red on RUSTSEC-2025-0134, the
unmaintained warning for rustls-pemfile.  The commit that drops
rustls-pemfile has to land before this one is green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
nginx#344 replaces rustls-pemfile with rustls-pki-types (RUSTSEC-2025-0134);
nginx#345 drops hyper's "http2" feature, removing h2 and fnv
(RUSTSEC-2026-0258). The control API is HTTP/1.1 only, so the feature
was never usable against the server -- but unitctl also stops offering
HTTP/2 in the ALPN list for any remote (TLS) control API connection,
including through a proxy in front of it. That is a separate Change
entry from the Security one.

One entry pair on this branch, since it merges after nginx#344 and both
changes are present in master by the time this lands.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A descriptor attached to a port message is leaked whenever nothing takes
ownership of it: the dispatcher reclaimed nothing a handler left behind, and
several paths never reach a handler at all.

The reach is wider than the router's own application ports.  An application
is given the write end of the router's MAIN port -- nxt_application.c sets
init->router_port.out_fd to that port's pair[1] -- and nxt_port_handler()
dispatches on the type byte with no sender check, so every handler in both
router tables is reachable from an application.  Among them GET_MMAP and
OOSM, which libunit sends as a matter of course and which never look at
msg->fd.  The 16-byte header is entirely attacker-chosen, type, stream and
the nf/mf fragment bits included.

The fragment paths run no handler:

  *) "goto fmsg_failed" skips dispatch when a fragment cannot be found or
     started, leaving msg->fd untouched.

  *) A middle fragment is chained into the assembled message without its
     fd[] being carried across.

  *) The last-fragment merge overwrote the fragment's own fd[] with the
     assembled message's.

So close at the tail of nxt_port_read_msg_process(), which covers the
handler and fragment paths alike, plus one close in the merge before the
overwrite.

This relies on the convention that a handler keeping a descriptor sets its
slot to -1 -- already followed by the port and main-process core, and now
followed everywhere.  Seven sites did not: three kept a descriptor without
clearing (the listen socket and TLS chain file in nxt_router.c, the log
descriptor in nxt_router_access_log.c) and four closed one without clearing
(two in nxt_controller.c, one each in nxt_router.c and
nxt_router_access_log.c).

Neither class fails as a leak, which is why both matter.  A kept descriptor
that is centrally closed is aliased by the next open() in that thread, so
the retained handle silently refers to something else; a closed one is
closed twice.  Getting this wrong shut the listening socket, reported by the
test suite as

    epoll_ctl(11, 1, 51) failed (9: Bad file descriptor)

and missing the access-log close produced

    close(53) failed (9: Bad file descriptor)

on log reopen -- found by exercising SIGUSR1 by hand, since no test covers
it.  Both are fixed here and verified absent: three reopen cycles log
correctly with no alerts.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
Drives nxt_port_rpc_handler() against a port whose rpc_streams hash is
empty, with real pipe descriptors attached to a stream nothing registered,
and asserts they are closed -- fcntl(fd, F_GETFD) failing with EBADF --
rather than asserting anything about the handler's return.  Covers both
arms that reach the early return (nxt_lvlhsh_find and nxt_lvlhsh_delete),
one and two descriptors, and a message carrying none.

Fails without the fix with "find, one fd leaked fd[0]", and the test binary
exits non-zero on failure, so the c-tests job catches a regression.

nxt_router_response_ready_handler() is not covered: reaching it needs a
full request and nxt_request_rpc_data_t fixture, well beyond what the
neighbouring tests set up.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
nxt_port_read_msg_process() (src/nxt_port_socket.c) now closes whatever a
dispatch leaves in msg->fd[], plus one close in the last-fragment merge
before msg->fd[0] is overwritten by the assembled message's own
descriptors.  Neither was covered: the existing tests all drive a handler
directly, never the dispatcher's own tail and fragment paths.

Adds nxt_port_fd_test_tail_close() and nxt_port_fd_test_frag_merge() to
src/test/nxt_port_fd_test.c, exposed via a new NXT_TESTS-only wrapper,
nxt_port_test_run_read_msg_process() (src/nxt_port_socket.c, declared in
src/nxt_port.h), following nxt_main_test_run_start_process_handler()'s
shape exactly.

Three cases, using two new test handlers (.oosm ignores the message
outright, .status blanks fd[0] without closing it -- a "keeps nothing" and
a "keeps fd[0]" handler):

  *) Tail close, handler ignores the message: both real descriptors end up
     closed and both msg->fd[] slots at -1.  Reverting nxt_port_socket.c to
     63a992f8^ (the fix's parent) and rebuilding reproduces the pre-fix
     behaviour; the test fails with "port fd test: dispatch to a handler
     that ignores the message left fd[0] open".

  *) Tail close, handler keeps fd[0]: fd[0] stays open, fd[1] (never taken)
     is closed.  This already passes on the pre-fix revision -- it exists
     to catch a future unconditional close, not a current leak, and is
     documented as such in the test's comment rather than presented as
     catching the bug.

  *) Fragment merge: a first fragment (nf=0, mf=1) carries descriptor A, a
     last fragment (nf=1, mf=0) on the same (stream, pid) carries a
     different descriptor B.  With the ignoring handler, both A and B end
     up closed (A via the tail close once fmsg->fd[0] is dispatched, B via
     the merge close before the overwrite).  With the keeping handler, A
     stays open and B is closed.  Deleting only the merge close
     (nxt_port_close_fds(msg->fd) before msg->fd[0] = fmsg->fd[0]) and
     rebuilding, with the ignoring handler, reproduces "port fd test:
     fragment merge, handler ignores the message leaked B, the last
     fragment's own descriptor" -- confirming that assertion is the one
     that actually depends on the merge close, not on the tail close it
     sits next to.

Both revert experiments used a scratch copy of nxt_port_socket.c and were
discarded before this commit; the working tree here has only the fix and
the new test.  ./build/tests exits non-zero on either injected regression.
test/test_static.py -q still passes (23 passed, 1 skipped).

nxt_router_response_ready_handler() stays uncovered, as before: it needs a
full request and nxt_request_rpc_data_t fixture well beyond this file's
scope.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
With the port writable and its queue empty, nxt_port_msg_chk_insert()
declines and nxt_port_socket_write2() sends inline.  If the socket answers
EAGAIN and nxt_port_msg_insert_tail() then cannot allocate, the message is
neither sent nor queued -- and write2() still answered NXT_OK, because
nxt_port_write_handler() returns void and nothing carried a status back.

A caller that answers an RPC and then sends a fallback loses both.  The
reply reads NXT_OK, so it clears the state that would have made the
fallback carry the answer; and the fallback dies with it, because the
EAGAIN cleared the port's write_ready, so that second message is queued
rather than sent and the error handler scheduled by the first drains it.
The port stays open throughout -- nxt_port_error_handler() completes
buffers and fixes the use count, and closes nothing -- so nothing else
reports it either.  nxt_proto_child_exited() is the case that found this:
its RPC_ERROR and the REMOVE_PID behind it are exactly that pair.

Reporting it as NXT_ERROR is only safe if nothing was consumed, because
src/nxt_port.h gives the caller back fd, fd2 and b on any answer but
NXT_OK.  On this exit nothing was: nxt_socketpair_send() sent no bytes and
no descriptor, and nxt_port_msg_close_fd() runs only after a successful
send.  So leave the message whole and answer NXT_ERROR, which is the state
every caller already handles for the allocation failure in chk_insert().

Only while this is still the first fragment.  Once one has gone out, ->nf
is set, the descriptor is closed and the sent buffers completed, so the
message is no longer the caller's to clean up -- a payload over max_size,
or a chain longer than NXT_IOBUF_MAX, reaches that.  There the port keeps
it and nxt_port_msg_drop() finishes it, as before.

Leaving the loop on that exit re-arms the write event, where the old
"goto fail" raised the error handler.  The socket is alive -- this was a
full socket buffer and a failed allocation, not a dead peer -- and without
the re-arm nothing sets write_ready again, so everything queued on that
port from then on would wait for a writable event that never comes.

A send that fails outright keeps its old treatment: the message is dropped
and NXT_OK returned, even though that answer is wrong in the same way.
That path is taken by every worker that dies with a send in flight, and
the callers that ignore this return were written for it -- they hand over
a buffer and rely on the port to complete it.  Reporting it there would
leak those buffers -- websocket frames among them are shared-memory
chunks that no pool teardown reclaims -- so it belongs with those call
sites rather than here.

src/test/nxt_port_fail_test.c drives the real thing: a socketpair with a
4 KB send buffer filled to EAGAIN, then the allocation hook armed.  It
asserts the answer, that the descriptor is still open, that no completion
was queued once the work queue has been drained, that the port's queue is
empty, and that the write event was re-armed exactly once.

A payload that reached the shared queue answers NXT_OK whatever becomes
of the wake-up that follows it, because the ring has taken the buffer and
queued its completion by then; nxt_runtime_port_send_quit() is a caller
that would otherwise complete it twice.  That case predates this change --
the allocation failure in nxt_port_msg_chk_insert() could already answer
NXT_ERROR there -- and the lost wake-up with it: nxt_port_queue_send()
raises "notify" only on the 0-to-1 transition, so the item waits for the
next message that takes this port's socket path, which is when
nxt_port_queue_read_handler() drains the ring.  That wait is now alerted
rather than silent.

The re-arm itself can fail.  Posted across engines it allocates the work
item it carries, under the same pressure that sent the write down this
path, and its result was discarded -- leaving write_ready at 0 with no
event to set it again, which is the stall the re-arm exists to prevent.
It now raises the error handler when the post fails, the way every other
failure in this function does, and says so.

Fixes: nginx#335
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Seven test files carried the same helper, each under its own prefix:

    static nxt_bool_t
    nxt_<file>_fd_is_open(nxt_fd_t fd)
    {
        return fcntl(fd, F_GETFD) != -1;
    }

The prefixes exist because every test object links into one binary, not
because the copies differ -- five were identical and the other two only
renamed it.  Two more files spelled the same test out by hand.

Put it in src/test/nxt_tests.c with a prototype in nxt_tests.h, where the
suite already keeps shared support, and drop the copies.  A definition in
a translation unit rather than a header also keeps the build quiet: a
static helper in a header would want an inline marker and would trip
-Wunused-function in every file that did not call it, and the tree builds
tests with -Wall -Wextra -Werror.

src/test/nxt_unit_port_recv_test.c keeps its own spelling.  It is not part
of the tests binary -- auto/make links it from its own object alone -- so
it cannot reach nxt_tests.c.

No behaviour changes: the helper is the same expression it replaced, and
the suite runs 50/50 in release and debug.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Unit emits ETag and Last-Modified on every static response and then ignores
every validator a client sends back: a matching If-None-Match still gets the
full 200.  Every repeat view of a page re-ships every byte of every image,
which for a media-heavy site -- a WordPress uploads tree, say -- is most of
the traffic.

Implement the precondition ladder of RFC 9110 Sect. 13.2.2 for GET and HEAD,
in the order that section mandates: If-Match, then If-Unmodified-Since, then
If-None-Match, then If-Modified-Since.  The later member of each pair is
consulted only when the earlier one is absent, so a client that sends both a
tag and a date is judged by the tag even when the tag does not match.  A
failed If-Match or If-Unmodified-Since is a 412; a matching If-None-Match or
an unchanged If-Modified-Since is a 304.

Entity-tag comparison follows Sect. 8.8.3.2: If-Match compares strongly, so
a W/-prefixed tag never matches there, while If-None-Match compares weakly
and strips the prefix.  "*" matches any representation, but only as the
whole field value -- the grammar is "*" / #entity-tag, not a list member.
An unparsable date is ignored rather than treated as an error.

The response framing needed no work: nxt_http_request_is_bodyless_final()
already treats 304 as bodyless and the h1 sender already skips chunked
framing and keeps the connection alive for it, so a 304 goes out with the
validators, no Content-Length and no Transfer-Encoding.  The 412 status line
was already in the h1 table; only the enum constant was missing.

One trap worth recording: request headers land in r->inline_fields and only
spill into the r->fields list, so the obvious nxt_list_each(f, r->fields)
walk compiles, runs, and silently matches nothing on an ordinary request.
nxt_http_fields_first()/_next() cover both, as nxt_router.c does.

test_static_conditional_ignored pinned the old behaviour and is replaced by
four tests of the new one.  test_static_range_ignored stays: Range is still
unimplemented, and ignoring it is still correct.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
nxt_http_static_preconditions() kept a single field pointer per header and
overwrote it on each hit, so only the LAST line of a repeated header was
evaluated.  RFC 9110 Sect. 5.3 makes repeated field lines equivalent to one
line holding the comma-separated concatenation.

The If-Match case refused legitimate requests.  Measured on a 10-byte file:

    If-Match: "<current etag>"
    If-Match: "other"
    -> 412, where the combined list "<current etag>", "other" gives 200.

If-None-Match had the mirror-image bug: a first line naming the current
entity-tag was discarded and the response was a full 200 instead of 304.

Both headers are "#entity-tag" lists whose members are OR'd, so evaluating
every line and remembering whether any matched is exactly the concatenation
the RFC asks for, without buffering the lines.  The date headers keep their
existing last-line-wins behaviour: repeating them is not meaningful and the
RFC gives no combining rule for a non-list field.

Found by an adversarial test pass.  The new test sends genuinely separate
field lines (the harness emits one line per list element, test/unit/http.py)
and fails without this change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
The CHANGES entry landed with the feature; docs/changes.xml did not.  Both
are maintained together -- the release notes are generated from the XML.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
Review of nginx#338 found two ordering bugs at the seams with existing response
processing.  Both reproduce; both are fixed here.

1. Preconditions ran before content negotiation, so a 304 or 412 displaced a
   406 that the request had already earned.  Measured on a compressible file
   with compression configured:

       Accept-Encoding: identity;q=0, *;q=0          -> 406
       ... plus If-None-Match: *                     -> 304   (wrong)
       ... plus If-Match: "nope"                     -> 412   (wrong)

   RFC 9110 Sect. 13.2.1 evaluates preconditions only for a request that
   would otherwise succeed.

   The fix could not simply move nxt_http_comp_check_compression() ahead of
   the precondition test: that function decides acceptability AND applies the
   decision, adding Content-Encoding and initialising the compressor.  A 304
   would then advertise an encoding it does not send, and leak the
   compressor, which is torn down by the last deflate() call that a 304 never
   makes.  So it is split in two -- nxt_http_comp_check_acceptable() decides
   and remembers, nxt_http_comp_apply_compression() applies -- and the static
   handler puts precondition evaluation between them.  The application
   response path in nxt_router.c always sends a body and calls both together;
   its behaviour is unchanged.

2. Preconditions compared against the ETag Unit derives from the file, but
   "response_headers" can replace or remove that header before it is sent
   (nxt_http_set_headers.c), so the comparison was against a validator the
   client never received.  With ETag configured as "release-42":

       ETag: "release-42"          advertised on an ordinary GET
       If-Match: "release-42"      -> 412   (its own tag refused)
       If-None-Match: "release-42" -> 200   (no 304 where one was due)

   The 412 is the damaging half: a legitimate conditional request denied.

   Policy: when the matched action overrides ETag or Last-Modified, do not
   evaluate preconditions at all.  That loses the 304 for those
   configurations and is never wrong, whereas comparing against the internal
   tag answers a question the client did not ask.  Only the header NAME is
   inspected -- the value may be a template, and resolving it here would move
   tstr queries ahead of where nxt_http_set_headers() runs them.

Tests: 406 precedence and a 304 carrying no Content-Encoding, in a new
test_static_compression.py (compression configuration is not reversible
within one unitd, nginx#167, so it needs --restart like test_php_compression.py);
the validator override; conditional HEAD; and a 304 followed by a normal GET
on the same kept-alive connection, since every existing conditional test
sends "Connection: close" and so did not establish that claim.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
unitctl pulled in nu-json to read hjson.  That crate brings a Nushell
utility layer with it: 30 crates in the tree of a tool that speaks one
JSON control API.  No document in the repository mentions hjson outside
the --help string.

Stdin with no file name used hjson for /config.  It now uses JSON.  hjson
is a superset of JSON, so piping JSON is unchanged; comments and unquoted
keys stop working.

".hjson" and ".cjson" files are still recognised, and refused with a
message that names hjson.  The alternative, letting them fall through to
the JSON parser, reports a syntax error on the first comment and never
says why.

nu-json also switched serde_json's preserve_order on for the whole graph.
unit-client-rs asks for that feature itself and needs it, so the feature
stays; it now has one source instead of two.

Measured with cargo tree --edges normal: 172 crates before, 142 after.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ddde8ee (step6-drop-hjson) drops nu-json from unitctl. Document the two
user-visible effects: stdin to /config is now parsed as JSON, and
.hjson/.cjson files are refused by name instead of hitting a misleading
JSON parse error.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A share with compression configured answers 406 when the client refuses
every coding it could offer.  That exit returns without closing the file it
has already opened, while every other bodyless exit in the function -- the
304, 412 and 416 branches, and "fail:" -- closes first.

So one unauthenticated request leaks one descriptor:

    Accept-Encoding: identity;q=0, *;q=0

Measured on a compressible file with gzip configured: ten such requests left
ten descriptors open on it in /proc, and ten ordinary 200s left none.
Repeating it exhausts the router's table, which stops every application
behind that router.

This is not new in the unreleased tree.  The same "return" without a close
is in 1.35.4, 1.35.5, 1.36.0 and 1.36.1 -- every release since compression
was added -- so it is a fix to shipped code, not to work in flight.  An
earlier reading of mine, and a review, both put its origin in the
conditional-request work that reorganised this function; checking the tags
shows the branch predates it and the reorganisation only moved it.

Verified after the fix: twenty such requests, zero descriptors held, and the
406 itself unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
Unit builds a static file's ETag from its mtime and size, so the gzip
response and the identity response advertise the same strong validator.  RFC
9110 Sect. 8.8.3 requires a strong validator to change whenever the selected
representation changes, and a content coding selects a different
representation.

Inert until something compares strongly.  If-Range does: Sect. 13.1.5
mandates the strong comparison, so a client that took its tag from a gzip
response, then resumed with that tag and a Range, matched -- and the range
path serves identity bytes, because it skips compression deliberately.  The
client appends identity bytes at offsets it believes are gzip offsets and
its saved file is silently corrupt.  Download managers and "curl -C -" do
exactly this; browsers do not.

Weaken the tag when a coding is applied, in nxt_http_comp_apply_compression()
where the Content-Encoding header is added.  The strong comparison then
fails, so If-Range is ignored and the whole representation is sent.
If-None-Match is unaffected: it compares weakly, so revalidating a coded
representation still answers 304.

All three servers checked do this, differing only in how: nginx weakens with
ngx_http_weak_etag() from its gzip header filter, Apache appends "-gzip"
inside the quotes, and Go's net/http appends the coding name.  Weakening is
the smallest of the three and needs no allocation beyond the prefix.

Measured, gzip configured for text/css: identity gives "6aa71a84-1d4c" and
gzip gives W/"6aa71a84-1d4c"; If-Range with the gzip tag now answers 200
where it previously answered 206, If-Range with the identity tag still
answers 206, and If-None-Match with the gzip tag still answers 304.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
A "share" action now answers a single-range "Range" request with 206 and a
"Content-Range" header, an unsatisfiable one with 416, and advertises
support with "Accept-Ranges: bytes".  "If-Range" is honoured, so a range is
served only while the client's copy is still current.

The send path already served an arbitrary window of a file:
nxt_http_static_body_handler() works from fb->file_pos to fb->file_end and
nxt_http_static_buf_completion() reads positionally, so serving bytes A..B
is file_pos = A, file_end = B + 1.  There is no sendfile(2) path in the
static handler and the 206 and 416 status lines were already in the h1
tables, so the router is untouched -- contrary to the 2023 assessment on
nginx#1011 that this needed "medium changes to the Unit Router".

Deliberately single-range only.  A multi-range request falls back to a full
200, which a server may always do, and that sidesteps the whole
CVE-2011-3192 class: Apache had to add overlap and reversal counting with
caps of 200 ranges, 20 overlaps and 20 reversals, and Go caps the summed
range size against the file size, purely to bound multipart output.  None of
that is needed while only one range is served.

Compression is skipped for a satisfiable range: coding a byte slice would
either compress the wrong bytes or require re-deriving which coded bytes
correspond to the requested identity range.  Serving the range from identity
is what nginx does in effect, by disabling ranges entirely once its gzip
filter runs.

A HEAD is range-processed exactly like the GET it stands for and differs
only in sending no body.  Sect. 14.2 reads like an argument for ignoring
Range on a HEAD, and that was tried; but Sect. 9.3.2 asks a HEAD to send the
headers the GET would have sent, and nginx, Apache and Go's net/http all
answer 206 with Content-Range to a HEAD, with "curl -I -r" relying on it.

Two defects found while building it, folded in rather than left as history:

  *) A suffix range against a zero-length file answered 206 with the
     malformed "Content-Range: bytes 0--1/0".  Sect. 14.4 makes any range
     unsatisfiable against a zero-length representation.

  *) The range number parser accumulated digits unbounded, and a value that
     wrapped negative passed both bounds tests: "rest" then went negative,
     nxt_min() cast it to a huge size_t, the buffer allocation failed and the
     request was abandoned with the file still open.  "bytes=9223372036854775808-"
     returned 206 with a negative Content-Range and leaked one descriptor per
     request.  Values now saturate at NXT_OFF_T_MAX, which is also the RFC
     answer at both ends.

The Content-Range buffer is sized for three %O conversions rather than two.
With two, 40 digits are shared among start, end and size: 13 each fits, 14
does not, so a file of about 10 TB with a range near its end truncated the
header.  nxt_sprintf() clamps at the boundary, so the value was cut rather
than the buffer overrun -- a well-formed but wrong header, which for a
resuming client is worse than a crash.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
Written to break the feature rather than confirm it, after its own tests
were green.  They found two defects, both folded into the implementation
commit: the zero-length suffix range, and the wrapped range value that
leaked a descriptor per request.

Covers numeric overflow at both ends, ranges spanning the 128 KiB buffer
boundary with byte-exact slice assertions, 24 threads against one file
proving no stale file_pos leaks through the per-thread buffer freelist, the
full Sect. 13.2.2 precedence matrix, HEAD, Accept-Encoding interaction, and
the share features -- index, fallback, types, directory redirect -- being
unaffected by a validator or a Range.

Every 206 and 416 asserts its Content-Range, not just its status.  That is
the lesson from the zero-length bug: it survived a fully green suite because
the tests checked status and body length, and a 206 whose Content-Length is
0 looks benign until the header itself is read.

test_static_range_gzip needs --restart because compression configuration is
not reversible within one unitd (freeunitorg#167); it is skipped
otherwise.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
serde_yaml is archived since 2024-03-25 and pulls unsafe-libyaml, a
c2rust transpile of libyaml with 241 unsafe sites, archived since
2024-03-21.  RustSec has no unmaintained advisory for either
(advisory-db#2132 is still open), so cargo audit does not warn and will
keep not warning.

Input and output cannot be separated.  serde_yaml has no Cargo features,
so linking it for one half links both, and the emitter is the transpiled
code too: serde_yaml/src/libyaml/emitter.rs drives unsafe-libyaml's
emitter.rs, 52 of those 241 unsafe sites.  Every serde-integrated YAML
crate on crates.io still carries unsafe-libyaml or its rename
unsafe-libyaml-norway, so a swap keeps the transpile; serde_yaml_bw adds
regex, base64, saphyr-parser, zmij and num-traits on top of it.  A
hand-written emitter would have to reproduce YAML 1.1 plain-scalar
resolution over arbitrary operator strings, where a missing quote is
silent data corruption.  So both go, and yq covers the format.

The Yaml input variant stays in InputFormat.  Deleting it would make a
".yaml" file InputFormat::Unknown, and execute.rs and import.rs end
their format branch with panic!("Unknown input file type").  Keeping it
inside is_config() routes the file to a message naming YAML instead of
an abort.

"unitctl status -t yaml" is gone; clap refuses the value and lists the
formats that remain.  The docs site shows that example and needs the
same change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
023cf7e (chore/unitctl-drop-serde-yaml) drops serde_yaml and
unsafe-libyaml from unitctl. Merge this into the existing hjson removal
entry rather than adding a second one: both are the same unreleased
1.36.2 stanza, and the hjson entry's "supported input formats are now
json, json5, yaml and pem" sentence would otherwise sit right above a
new entry contradicting it. Document the refusal messages for both
".hjson"/".cjson" and ".yaml"/".yml", the removed "unitctl status -t
yaml" example, the narrowed --output-format values, and that
tools/unitc keeps a supported YAML path via yq in both directions.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
unitctl talks to the control API over a UNIX socket or over TCP.  The
control API has no TLS listener of its own, so the HTTPS connector is
there for one case: a TLS-terminating proxy in front of a remote control
API.  That is a real deployment, so the connector stays.  It is now a
build-time choice.

The cost of always having it is a C toolchain.  hyper-rustls pulls in
rustls, rustls pulls in aws-lc-rs, and aws-lc-sys builds a C library with
cmake.  Off, the dependency graph loses 11 crates counted with
--edges normal (142 -> 131) and 19 counted with --edges normal,build
(150 -> 131), among them aws-lc-sys, cc and cmake.  The musl artifact is
the one that wants this: it is meant to be a static binary that builds
anywhere, and with the feature off it builds on a host that has neither
cmake nor a musl C compiler.

hyper-rustls and the direct rustls dependency are gated together.  That
rustls line is not used in any code; it is there so that rustls gets its
own default features.  Measured with "cargo tree -e features": every
rustls feature except one is turned on twice over, by hyper-rustls's
defaults as well, but "prefer-post-quantum" comes from the direct
dependency alone.  Gating one without the other would drop it, and cargo
would not say a word.  With the feature on the feature tree is
byte-identical to before, so the provider is unchanged: aws-lc-rs, no
ring.

With the feature off an "https://" control socket is refused where the
address is parsed, naming the feature, rather than being handed to a
plain HTTP connector that would fail later with an unrelated message.

The TCP connector type moves behind a type alias, so RemoteClient keeps
both of its variants in both builds and no match arm is left dangling.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The musl build no longer accepts an https:// control socket address, and there
is a new build option, so both belong in the release notes rather than only in
the PR.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
target_feature_flags keys on a target name, so it reached only the cross builds
that name one. A native build on a musl host passes no --target: "make release"
on Alpine, which is how a distro packages this, kept TLS and compiled
aws-lc-sys. That is the case the feature exists for.

Ask rustc for the host triple and apply the same rule to the native debug and
release recipes. HOST_TARGET is empty when rustc is absent, which leaves the
flags unchanged.

Verified with make -n: a glibc host builds unchanged; with the host reported as
musl both native recipes gain --no-default-features; the cross rule is
untouched.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The release and debug recipes take HOST_FEATURE_FLAGS; "make test" did not, so
on a musl host it still built aws-lc-sys through cmake, and
refuses_https_without_the_tls_feature never ran there -- the one test that
covers the state this feature exists for.

Also correct a number in the merged YAML entry. It said unsafe-libyaml carries
241 unsafe lines. On the pinned 0.2.11 that matches nothing: src/ has 224 lines
containing "unsafe", 218 of them "unsafe fn", and 249 across the whole crate
including tests. Say 218 unsafe functions, which is scoped and reproducible with
grep -rho 'unsafe fn' src/*.rs | wc -l.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Unit emitted no Vary header, ever -- "grep -rn Vary src/" found nothing.
With compression configured the same URL returns either an identity or a
gzip representation depending on the request, so a shared cache was entitled
to store whichever it saw first and serve it to everyone: gzip bytes to a
client that cannot decode them, or the uncompressed copy to one that could
have had the small version.

Emit "Vary: Accept-Encoding" once the response is known to have been
negotiated -- past every early return in nxt_http_comp_check_acceptable()
that means "this was never subject to negotiation", so a file outside the
configured types, or a response with compression disabled, does not carry
it.  A Vary already set by response_headers or another producer is left
alone.

Sent on the identity response as well as the coded one.  The identity
response is precisely the one a cache must not reuse for a gzip-capable
client, so omitting it there would leave the hole open from the other side.

This completes the pair started by weakening the entity-tag of a coded
representation: that made revalidation distinguish the two representations,
this makes the cache key distinguish them.  Either alone still lets a shared
cache mix them.

Closes freeunitorg#357.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
The first version returned early when any Vary was already present, on the
reasoning that another producer's header should be left alone.  That is
backwards: a response carrying "Vary: Origin" still varies on the coding too,
and leaving it untouched keeps Accept-Encoding out of the cache key -- the
exact hole this is meant to close, now with the header present and looking
correct.

Merge instead.  An existing "Vary: *" is left alone, since it already varies
on everything and narrowing it would say less.  A list that already names
Accept-Encoding is left alone.  Otherwise the token is appended.

Comparison is per token rather than by substring, so "X-Accept-Encoding" is
correctly treated as a different header and gets Accept-Encoding appended.

Reachable from an application response: the static path has nothing that sets
Vary before this runs.  Measured with a PHP app that sets the header and a
Content-Length, gzip configured for text/html*:

    (none)              -> Accept-Encoding
    Origin              -> Origin, Accept-Encoding
    Accept-Encoding     -> Accept-Encoding
    *                   -> *
    X-Accept-Encoding   -> X-Accept-Encoding, Accept-Encoding

A Vary set through "response_headers" still wins, because
nxt_http_set_headers() runs after this and replaces the value outright.  That
is the same precedence "response_headers" has over every generated header,
and matches how an ETag override is handled; it is a deliberate operator
override rather than something to defend against here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
The wildcard test skipped leading whitespace but not trailing, so "Vary: * "
fell through to the append and produced "* , Accept-Encoding" -- not a valid
field value, and a narrowing of a header that already varies on everything.

Trim both ends before the comparison, and re-anchor the token scan to the
field's real end afterwards so the trim cannot shorten what is copied.

These are response fields an application handed to libunit, not request
headers the parser has normalised, so trailing whitespace can genuinely
arrive here.

Honest limit on the verification: PHP appears to normalise the trailing
space before libunit sees it, so "Vary: * " through a PHP app reaches this
code already trimmed and the new branch is not exercised by that test.  The
wildcard, leading-space and both-ends cases all return "*" unchanged, and
"Origin " merges to "Origin, Accept-Encoding" with no stray space -- but a
runtime that does not normalise is what the trim is there for, and I have
not demonstrated one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
Two observations from review, both minor, both worth closing.

The outer loop was a "for" with p++, and the inner scan can leave p at end;
incrementing there forms a pointer past one-past-the-end, which C does not
define even where every real target treats it as harmless.  A while loop
that advances only when there is something to advance past avoids
constructing the pointer at all.

An empty existing value made the append emit a leading comma --
", Accept-Encoding".  There are no tokens to search or append to in that
case, so replace rather than append.

The mirror case turned up while testing the first: a value ending in a
separator, "Origin,", appended to give "Origin,, Accept-Encoding".  Both
forms are legal -- Sect. 5.6.1.2 permits empty list elements and readers
ignore them -- but there is no reason to emit one.  The append now starts
after the last real token.

Measured across the edges, gzip configured for text/html*:

    (empty)             -> Accept-Encoding
    Origin              -> Origin, Accept-Encoding
    a, b, c             -> a, b, c, Accept-Encoding
    Origin,             -> Origin, Accept-Encoding
    Origin,<space>      -> Origin, Accept-Encoding
    a, Accept-Encoding  -> a, Accept-Encoding
    *                   -> *
    *<space>            -> *

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
nxt_http_set_headers() runs after the Vary is generated and replaces a field
it names outright, so "response_headers": {"Vary": "Origin"} emitted only
"Vary: Origin", and {"Vary": null} removed the header entirely.  Either way
the response still varied on Accept-Encoding, so a shared cache was free to
serve one coding to every client -- the exact bug this header exists to
prevent, reintroduced by configuration.

I argued earlier that this was simply the precedence "response_headers" has
over every generated header, as with an overridden ETag.  That was the wrong
read of the precedent: nginx#338 did not ignore the ETag interaction, it handled
it, by skipping preconditions when the validator is overridden.  The
consistent treatment here is to handle it too.

Mark the response when it was chosen by negotiation, and re-assert the
header after "response_headers" has run.  The merge is idempotent -- it
leaves "*" alone, leaves a list already naming the header alone, and re-adds
the field when it was removed -- so re-running it is enough.

An operator writing "Vary: Origin" is almost always adding CORS and does not
know Unit generates the field at all; taking that as an instruction to drop
the coding from the cache key serves nobody.

Measured, gzip configured for text/css:

    (no response_headers)   -> Accept-Encoding
    Vary: Origin            -> Origin, Accept-Encoding
    Vary: null              -> Accept-Encoding
    Vary: *                 -> *
    Vary: Accept-Encoding   -> Accept-Encoding

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BvcUzwdMNFyRDBE1Exvjf
A write that cannot be sent now and cannot be held for later leaves the
port's write event disarmed, and only port->engine may arm it again.  A
caller on another engine had to ask through nxt_port_post(), which
allocates the work item it posts -- and that allocation fails under
exactly the memory pressure that sent the write down this path, since the
write got here because nxt_port_msg_insert_tail() could not allocate
either.

The failure was silent in the way that matters: nxt_port_error_handler()
drains what the port holds, but nothing sets write_ready back and no
event is armed, so every later message on that port was queued and never
sent until the port closed.  With "limits": {"timeout"} unset, requests
routed there wait rather than fail.

So the port carries the item.  ->rearm_work is posted instead of an
allocated one, and ->rearm_pending, taken from 0 to 1 by the poster and
cleared by the handler, keeps it off the engine's queue twice: the queue
links tail->next without checking, so one item posted twice becomes its
own successor and nxt_locked_work_queue_add() spins.

->release_work could not be reused and its guarantee does not carry over.
It is posted only by the thread that CASes the last reference away, so at
most one is ever in flight by construction; nothing like that holds for a
re-arm, which any thread can want at any time.  What does carry over is
the reference: the item takes one, and the handler drops it on
port->engine, so the port cannot be released while the item is queued.

The handler also checks pair[1].  A port can be closed while the item is
in flight, and nxt_port_write_close() leaves socket.fd at the number it
had, so arming would hand that number -- possibly somebody else's by then
-- to this port's handlers.  Every close runs on port->engine, so the
read is stable.  This was already reachable through the old
nxt_port_post(nxt_port_fd_enable_write) path.

A lost queue marker rides along, because it needs the same thing.  When a
payload reaches the shared ring and the READ_QUEUE marker cannot be
written, the ring has taken the buffer, so the write must still answer
NXT_OK -- but nothing tells the peer to look, and nxt_port_queue_send()
raises "notify" only on the 0-to-1 transition, so no later enqueue
announces it either.  After EAGAIN the peer recovers by itself: that
errno means the socket holds data it has not read, and
nxt_port_queue_read_handler() drains the ring before the socket.  After
ENOBUFS it promises nothing.

->announce records that a marker is owed -- a fact about the port, not
work to run, so a flag and not a second item.  nxt_port_announce() sends
the header from the stack with one sendmsg() and no allocation, and
clears the flag only once it has gone.  A marker that lands makes the
peer drain the whole ring, so anything enqueued meanwhile is covered.
The attempt is made from the re-arm handler rather than left to the write
event, because after ENOBUFS the socket never became unwritable and there
may be nothing for the write path to do; the handler is already running on
the right engine, so it costs one sendmsg() to try.

Three legs in src/test/nxt_port_fail_test.c, each red without its guard:
the posted item is the port's own and a second re-arm does not queue it
again ("a second re-arm posted the same item again (signals 2 use_count
3)"); a port closed while the item is in flight is not armed ("the re-arm
enabled the write event of a closed port"); and the owed marker reaches
the peer as a READ_QUEUE header once the socket drains ("the queue marker
was still owed after the port became writable").

An owed marker is retried from every later pass through this function,
not only from the one that finds the write event disarmed: the first
retry runs in the re-arm handler, which arms the event, so nothing would
ask again and a second ENOBUFS would strand the marker.

nxt_port_fd_block_write() still goes through an allocating post whose
return nobody reads.  It is the same failure with the opposite effect --
the event stays armed on a full socket rather than disarmed on an empty
one -- and it predates this change, so it is left to its own fix.

->rearm_pending counts posts, not re-arms.  A caller already on
port->engine does the work directly and touches neither the flag nor the
reference count: decrementing a flag no CAS had incremented wrapped it --
nxt_atomic_t is unsigned -- and every later cross-engine post was then
refused by the CAS, which would have stalled the port without needing an
allocation failure at all.  The inline leg asserts the flag is untouched
after a same-engine re-arm, and the cross-engine leg asserts one in flight
survives a same-engine re-arm beside it.

Fixes: nginx#350
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
andypost and others added 26 commits October 4, 2026 18:44
The compressor context was one thread-local object for each router thread
(nxt_http_comp_compressor_ctx in src/nxt_http_compression.c). But the
router compresses an application response in several event loop turns.
nxt_router_response_ready_handler() calls
nxt_http_comp_compress_app_response() once for each message from the
application. Between two of these turns, another response on the same
thread can run nxt_http_comp_check_acceptable(), which reset the context,
and nxt_http_comp_apply_compression(), which initialised a new stream in
it. The last deflate() call of a response freed the stream.

So two application responses on one thread used the same stream. A client
could get the bytes of another response in a zstd or br body that decodes
without an error. Most gzip and deflate bodies were not valid, or stopped
early. The router could use a freed stream: it crashed in
ZSTD_compressStream2(), and ASan reports a double free of a brotli
encoder. Static responses were not affected, because they are compressed
in one call.

Now nxt_http_comp_check_acceptable() allocates the context from the
request pool and stores it in the new r->comp_ctx. The functions that
used the thread-local object get the context from the request.
nxt_http_comp_wants_compression() and nxt_http_comp_identity_refused()
now take the request.

The stream is now freed in one place. Each compressor has a new "free"
operation, and its deflate() no longer frees the stream.
nxt_http_comp_compress() frees the stream after the last call or after a
failed call. A request pool cleanup frees it when the response stops
early: the client closed the connection, the application failed, or the
application timeout expired. Before, such a stream was not freed. A
failed zstd call and a static response that failed before its first
deflate() call also did not free it. The "live" flag in the context makes
sure that a stream is freed only once, and that no call uses it after the
free.

test/test_python_compression.py streams 8 writes of 4096 bytes from a
Python application. Each body holds only a token of its own request. The
tests send 24 requests at once with each compressor that the build has,
decode each body and look for the tokens of other requests. Two tests
also close 4 responses in the middle of the body: one with a client
reset, one with the application timeout. On 8 CPUs, with the default
router threads, each of the 12 tests failed in 10 of 10 runs before this
change, with 21 to 24 of 24 gzip responses bad in each run. With a no-op
cleanup, an ASan build reports the 4 streams of each closed test as
leaks.

The thread-local context came with response compression in 1.35.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewed-by: DeepSeek V4.1 Flash
The router decides on compression before "response_headers" are applied.
nxt_http_comp_check_acceptable() returned early only for a
Content-Encoding that was already in the response fields. A
Content-Encoding from "response_headers" is added later, in
nxt_http_request_header_send(), and nxt_http_set_headers() then replaced
the value of the field that the compressor had added.

So a share of "$uri.gz" with "Content-Encoding: gzip" in
"response_headers" sent gzip of the stored gzip file to a client that
accepts gzip. The field named one coding, and the ETag was weak. An
application response that sets its coding this way had the same fault. A
Content-Encoding removed with null in "response_headers" sent gzip bytes
with no Content-Encoding.

The new nxt_http_set_headers_field_op() says what "response_headers"
will do to a field. It matches the name without case, uses the same
status range as nxt_http_set_headers(), and lets the last matching key
win. The check uses it for both callers, the static handler and the
router.

A template value is resolved at the check, with the code that
nxt_http_set_headers() uses. The new nxt_http_set_headers_value() holds
it for both. It resolves each key once per request and stores the result
on the request, so nxt_http_set_headers() does not resolve that key
again. A JavaScript template therefore runs once, and the check and the
header see the same value. A value that is not safe in a field is not
sent, so it counts as absent, and an earlier key can then give the result.
A null value removes the field. A variable that is not set gives an empty
string. An empty string is a value, and the field is sent empty, as
before. A failed query makes the check return NXT_ERROR. A cacheable
variable in such a template keeps the value from the check for the rest
of the request, including the access log.

A configured value is now treated like a Content-Encoding in the
response: nothing is compressed, the ETag stays strong, and Vary is not
merged. A configured removal keeps the compressor out. The body is then
identity, so a client that refused identity gets 406. This applies only
to a coding that Unit would apply. When the response has its own
Content-Encoding, a configured removal still removes only the field.

Closes freeunitorg#557

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewed-by: Claude Fable 5.1 <noreply@anthropic.com>
Reviewed-by: Codex
Reviewed-by: DeepSeek
Dependabot only watched GitHub Actions. Add the Cargo projects that
have a Cargo.lock. test/requirements.txt is not added: no CI job
installs it, so a raised floor would merge untested.

Cargo updates come weekly. OpenTelemetry, tonic and prost crates move
together in one group. A group opens one pull request per directory,
so test/fake_otlp gets its own otel pull request. A second group with
"applies-to: security-updates" keeps the same crates together in
security updates, because a group covers version updates only by default. Other minor and patch updates of a directory share one more group.
The pull request limit is 2, and it counts per directory, not for the
whole block (dependabot/dependabot-core#10395),
so one run opens at most 16 pull requests.

Two ignore rules apply. Wasmtime is skipped entirely. Its version is
also pinned in pkg/contrib/src/wasmtime/version, EOL.md and
pkg/eol.json, which a Dependabot pull request cannot change, so it is
updated by hand and stays on the 48 line. This also stops Dependabot
security pull requests for Wasmtime; the weekly audit.yml run reports
its advisories instead. bindgen minor and major versions are
skipped. bindgen 0.68 produced empty structs under clang 22, and 0.72
is the version that was tested. See
https://github.com/freeunitorg/freeunit/blob/master/src/wasm-wasi-component/Cargo.toml

Not covered, on purpose: the generated pkg/docker/Dockerfile.* files,
the Docker files that use the floating tag rust:slim-trixie, the
and the vendored Wasmtime source tarball in pkg/contrib. The two
test/wasm_component fixtures are covered: the tests build a copy of
each with "cargo component build", which writes src/bindings.rs again,
and the exports do not come from that file.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Reviewed-by: DeepSeek
Reviewed-by: Codex
Apache Tomcat 9.0.122 fixes CVE-2026-87022, per
https://tomcat.apache.org/security-9.html#Fixed_in_Apache_Tomcat_9.0.122:
"WebSocket message smuggling with per-message-deflate". The fix is
apache/tomcat@959a52a
and it is in the 9.0.122 tag. The release fixes eleven other CVEs.

None of the twelve fixes is in a jar that the build downloads.

FreeUnit has its own copy of the vulnerable code in
src/java/nginx/unit/websocket/PerMessageDeflate.java, but no received
frame reaches it. The server side never installs the transformation,
does not answer with Sec-WebSocket-Extensions, and passes received
frames to the application without decompression. The client side
fails with a NullPointerException in the WsSession constructor before
it creates the frame reader. So this commit does not port the fix.
Whoever makes the client's connectToServer() work must port
apache/tomcat@959a52a
first, because that change makes the copied code reachable.

9.0.122 is the newest 9.0.x on Maven Central
(https://repo1.maven.org/maven2/org/apache/tomcat/tomcat-servlet-api/maven-metadata.xml).
Each new SHA512 was checked against the .sha512 file that Maven Central
publishes for the same jar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the runtimes that upstream now publishes:
- golang:1.27-trixie (Go 1.27 was released on 2026-08-19).
- perl:5.44-trixie (Perl 5.44 was released on 2026-07-15).
- eclipse-temurin:27-jdk-resolute (Java 27 was released on 2026-09-22).

The EOL dates come from https://endoflife.date (go, perl,
eclipse-temurin). Go 1.27 has no published EOL yet. Its date, 2027-08,
follows the same rule as Go 1.26: support ends at the second release
after it.

Eclipse Temurin has no 27-jdk-noble tag. Its only Ubuntu tag for Java
27 is 27-jdk-resolute (Ubuntu 26.04). VARIANT_java moves from noble to
resolute, so the Java 17, 21, 25 and 26 images move to Ubuntu 26.04
too. Each of them has a -jdk-resolute tag for amd64 and arm64.

Java 26 passed its upstream EOL on 2026-09-22. It gets the "EOL" note,
as Go 1.25, Node.js 20 and Perl 5.38 have. The four images stay in the
matrix for the 12-month grace period of pkg/eol.json.

The template ran no package upgrade. An image whose base is no longer
rebuilt upstream, such as node:20, kept the Debian packages of its
last base build. The template now runs "apt-get upgrade -y" after the
first "apt-get update", in the same RUN layer. The layer already ends
with "rm -rf /var/lib/apt/lists/*". The runtime stages of the three
pkg/docker/local/ Dockerfiles get the same step.

The Dockerfiles are regenerated with "make -C pkg/docker dockerfiles".
The CI matrices in build-test.yml and release-docker.yml read
pkg/eol.json, so they pick up the new versions with no workflow change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No crate declared "rust-version", so cargo could not report a toolchain
below the floor of a crate. Each crate now declares its floor. Each
floor was checked with "cargo check --locked" in the rust:<version>
image. The floor passed, and the release before it failed:

- src/wasm-wasi-component: 1.95. cranelift 0.135.5 requires 1.95.0.
  1.94.1 fails.
- tools/unitctl/unitctl and unit-client-rs: 1.95. sysinfo 0.39.6
  requires 1.95. 1.94.1 fails.
- tools/unitctl/unit-openapi: 1.86. icu_* 2.2.0 require 1.86. 1.85.1
  fails. The OpenAPI generator rewrites this Cargo.toml from
  openapi-templates/Cargo.mustache, so the template gets the line too.
- src/otel and test/fake_otlp: 1.88. tonic 0.14.6 requires 1.88.
  1.87.0 fails.
- pkg/eol and test/fake_upstream: 1.78. Their dependencies declare
  1.71 or less, but their Cargo.lock files are version 4. Cargo 1.77.2
  cannot parse them.
- test/wasm_component/hello_world and spin_loop: 1.78. The test
  harness builds them for wasm32-wasip1. That target name exists
  since 1.78. Rust 1.77.2 knows only wasm32-wasi.

pkg/docker/Dockerfile.builder-trixie and Dockerfile.builder-php8.5
installed Rust 1.94.1. That is below the 1.95 floor of
wasm-wasi-component, which the local wasm variant builds. They now
install 1.95.0, as the template and the release Dockerfiles do. The
builder image tag carries the Rust version, so the tag moves from
rust1.94.1 to rust1.95.0 in build-local.sh, the local/ Dockerfiles and
the READMEs. GHCR does not serve this image to an anonymous pull. If
the pull fails, build-local.sh builds the image locally, as before.

test/run-local.sh mirrors the template, so it moves to 1.95.0 too.
pkg/community/CENTOS.ALMALINUX.md now gives 1.88 as the Rust floor for
--otel. It said 1.94.1.

No dependency changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pull request jobs build the Rust crates with stable only.
build-deb.yml pins Rust 1.88.0 for src/otel, but it does not run on
pull requests. A Dependabot update that raises the Rust floor of a
dependency could pass its pull request and break the deb build. Codex
found this on
freeunitorg#565.

The new workflow .github/workflows/rust-version.yml has one leg for
each directory with its own Cargo.lock. These are the same eight
directories as the cargo entries in .github/dependabot.yml. Each leg
runs .github/scripts/check-rust-version.py. For every package, the
script reads "rust-version" from Cargo.toml, or from the workspace
when the package inherits it. It installs that toolchain with rustup
and runs "cargo +<version> check --locked" on the package. A package
without "rust-version" fails, so a floor cannot disappear silently.

Some legs need more setup:
- tools/unitctl generates the OpenAPI client first, and then restores
  the tracked unit-openapi/Cargo.toml that the generator rewrites.
- src/wasm-wasi-component installs libclang-dev and builds
  build/src/nxt_unit.o for its build script.
- The two test/wasm_component crates are checked for wasm32-wasip1.

The workflow runs on pull requests and on pushes to master that change
a Cargo.toml, a Cargo.lock, a rust-toolchain.toml, the OpenAPI
template or spec, or the workflow and its script. It uses only
actions/checkout, pinned by SHA, and the rustup that the runner has.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test/unit/applications/lang/wasm_component.py returns None when
"cargo component build" fails. test/unit/check/cargo_component.py then
reports the cargo_component feature as missing, and
test/test_wasm-wasi-component.py skips as a whole. The leg stayed
green while it tested nothing. So a dependency update that passes
"cargo check" in rust-version.yml but breaks the component build could
pass its pull request.

The step "Fail if the wasm smoke test skipped" already covered the
wasm leg, and its pytest output is already saved for both legs. The
step now runs for the wasm-wasi-component leg too. It requires a
PASSED line from test_<module>.py: test_wasm.py for wasm, and
test_wasm-wasi-component.py for wasm-wasi-component.

The comment on the build list said 23 legs. With Go 1.27 and Java 27
the matrix has 25.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1.36.2 was never tagged, and what master carries since 1.36.1 includes
two features (byte ranges and conditional requests for static files), so
the next release is 1.37.0 rather than a patch.  The changelog block
headed 1.36.2 becomes the 1.37.0 block; nothing in it is dropped.

  version                  NXT_VERSION 1.37.0, NXT_VERNUM 13700
  docs/changes.xml         both 1.36.2 blocks retitled, date set
  CHANGES                  header retitled by hand (see below)
  docs/unit-openapi.yaml   title
  tools/unitctl            crate versions, Cargo.lock, openapi-config,
                           README, and a 1.37.0 CHANGELOG section for
                           the unitctl changes merged since 1.36.1
  pkg/docker               "make dockerfiles"; the diff is the version only
  CHANGES, changes.xml     two entries for access-log changes that had
                           none: 279e1bb (object-format values escaped)
                           and 31fcf3e (invalid UTF-8 becomes U+FFFD)

CHANGES is edited by hand, not regenerated: "make -C docs changes" titles
the release "Changes with Unit" and wraps every entry differently from the
file the changelog commits have been maintaining.

The date, 2026-10-04, is the tag date.  This commit is rebased
onto master at the freeze and has to be the last one merged before the
tag, since every changelog commit in the merge train touches the same
block.
"make -C docs/ changes" does not produce the CHANGES in the tree: it
titles the release "Changes with Unit" and wraps every entry differently,
because the file has been kept by hand, one changelog commit at a time.
Following the documented step would rewrite the whole file.

The unitctl tag is created by unitctl.yml when the release tag is
pushed; pushing it by hand first makes that release job fail.  Say so,
and name the Docker Hub secrets release-docker.yml needs before the tag.
… 21 updates

Bumps the minor-and-patch group with 1 update in the /pkg/eol directory: [serde_json](https://github.com/serde-rs/json).
Bumps the minor-and-patch group with 1 update in the /src/otel directory: [tokio](https://github.com/tokio-rs/tokio).
Bumps the minor-and-patch group with 10 updates in the /src/wasm-wasi-component directory:

| Package | From | To |
| --- | --- | --- |
| [tokio](https://github.com/tokio-rs/tokio) | `1.52.3` | `1.53.1` |
| [anyhow](https://github.com/dtolnay/anyhow) | `1.0.103` | `1.0.104` |
| [bytes](https://github.com/tokio-rs/bytes) | `1.12.0` | `1.12.1` |
| [futures](https://github.com/rust-lang/futures-rs) | `0.3.32` | `0.3.34` |
| [futures-util](https://github.com/rust-lang/futures-rs) | `0.3.32` | `0.3.34` |
| [http](https://github.com/hyperium/http) | `1.4.2` | `1.5.0` |
| [http-body](https://github.com/hyperium/http-body) | `1.0.1` | `1.1.0` |
| [http-body-util](https://github.com/hyperium/http-body) | `0.1.3` | `0.1.5` |
| [hyper](https://github.com/hyperium/hyper) | `1.10.1` | `1.11.1` |
| [cc](https://github.com/rust-lang/cc-rs) | `1.2.66` | `1.5.1` |

Bumps the minor-and-patch group with 2 updates in the /test/fake_otlp directory: [tokio](https://github.com/tokio-rs/tokio) and [prost](https://github.com/tokio-rs/prost).
Bumps the minor-and-patch group with 1 update in the /test/wasm_component/hello_world directory: [bitflags](https://github.com/bitflags/bitflags).
Bumps the minor-and-patch group with 1 update in the /test/wasm_component/spin_loop directory: [bitflags](https://github.com/bitflags/bitflags).
Bumps the minor-and-patch group with 13 updates in the /tools/unitctl directory:

| Package | From | To |
| --- | --- | --- |
| [serde_json](https://github.com/serde-rs/json) | `1.0.150` | `1.0.151` |
| [tokio](https://github.com/tokio-rs/tokio) | `1.52.4` | `1.53.1` |
| [futures](https://github.com/rust-lang/futures-rs) | `0.3.32` | `0.3.34` |
| [http-body-util](https://github.com/hyperium/http-body) | `0.1.4` | `0.1.5` |
| [hyper](https://github.com/hyperium/hyper) | `1.10.1` | `1.11.1` |
| [serde](https://github.com/serde-rs/serde) | `1.0.228` | `1.0.229` |
| [serde_derive](https://github.com/serde-rs/serde) | `1.0.228` | `1.0.229` |
| [hyper-util](https://github.com/hyperium/hyper-util) | `0.1.20` | `0.1.21` |
| [hyper-rustls](https://github.com/rustls/hyper-rustls) | `0.27.9` | `0.27.10` |
| [which](https://github.com/harryfei/which-rs) | `8.0.5` | `8.0.6` |
| [bollard](https://github.com/fussybeaver/bollard) | `0.21.0` | `0.21.1` |
| [clap](https://github.com/clap-rs/clap) | `4.6.2` | `4.6.7` |
| [rustls-pki-types](https://github.com/rustls/pki-types) | `1.15.0` | `1.15.1` |



Updates `serde_json` from 1.0.149 to 1.0.151
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](serde-rs/json@v1.0.149...v1.0.151)

Updates `tokio` from 1.52.3 to 1.53.1
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](tokio-rs/tokio@tokio-1.52.3...tokio-1.53.1)

Updates `tokio` from 1.52.3 to 1.53.1
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](tokio-rs/tokio@tokio-1.52.3...tokio-1.53.1)

Updates `anyhow` from 1.0.103 to 1.0.104
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](dtolnay/anyhow@1.0.103...1.0.104)

Updates `bytes` from 1.12.0 to 1.12.1
- [Release notes](https://github.com/tokio-rs/bytes/releases)
- [Changelog](https://github.com/tokio-rs/bytes/blob/master/CHANGELOG.md)
- [Commits](tokio-rs/bytes@v1.12.0...v1.12.1)

Updates `futures` from 0.3.32 to 0.3.34
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/main/CHANGELOG.md)
- [Commits](rust-lang/futures-rs@0.3.32...0.3.34)

Updates `futures-util` from 0.3.32 to 0.3.34
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/main/CHANGELOG.md)
- [Commits](rust-lang/futures-rs@0.3.32...0.3.34)

Updates `http` from 1.4.2 to 1.5.0
- [Release notes](https://github.com/hyperium/http/releases)
- [Changelog](https://github.com/hyperium/http/blob/master/CHANGELOG.md)
- [Commits](hyperium/http@v1.4.2...v1.5.0)

Updates `http-body` from 1.0.1 to 1.1.0
- [Release notes](https://github.com/hyperium/http-body/releases)
- [Commits](hyperium/http-body@v1.0.1...v1.1.0)

Updates `http-body-util` from 0.1.3 to 0.1.5
- [Release notes](https://github.com/hyperium/http-body/releases)
- [Commits](hyperium/http-body@http-body-util-v0.1.3...http-body-util-v0.1.5)

Updates `hyper` from 1.10.1 to 1.11.1
- [Release notes](https://github.com/hyperium/hyper/releases)
- [Changelog](https://github.com/hyperium/hyper/blob/master/CHANGELOG.md)
- [Commits](hyperium/hyper@v1.10.1...v1.11.1)

Updates `cc` from 1.2.66 to 1.5.1
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](rust-lang/cc-rs@cc-v1.2.66...cc-v1.5.1)

Updates `tokio` from 1.52.3 to 1.53.1
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](tokio-rs/tokio@tokio-1.52.3...tokio-1.53.1)

Updates `prost` from 0.14.3 to 0.14.4
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Changelog](https://github.com/tokio-rs/prost/blob/master/CHANGELOG.md)
- [Commits](tokio-rs/prost@v0.14.3...v0.14.4)

Updates `bitflags` from 2.5.0 to 2.13.2
- [Release notes](https://github.com/bitflags/bitflags/releases)
- [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md)
- [Commits](bitflags/bitflags@2.5.0...2.13.2)

Updates `bitflags` from 2.5.0 to 2.13.2
- [Release notes](https://github.com/bitflags/bitflags/releases)
- [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md)
- [Commits](bitflags/bitflags@2.5.0...2.13.2)

Updates `serde_json` from 1.0.150 to 1.0.151
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](serde-rs/json@v1.0.149...v1.0.151)

Updates `tokio` from 1.52.4 to 1.53.1
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](tokio-rs/tokio@tokio-1.52.3...tokio-1.53.1)

Updates `futures` from 0.3.32 to 0.3.34
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/main/CHANGELOG.md)
- [Commits](rust-lang/futures-rs@0.3.32...0.3.34)

Updates `http-body-util` from 0.1.4 to 0.1.5
- [Release notes](https://github.com/hyperium/http-body/releases)
- [Commits](hyperium/http-body@http-body-util-v0.1.3...http-body-util-v0.1.5)

Updates `hyper` from 1.10.1 to 1.11.1
- [Release notes](https://github.com/hyperium/hyper/releases)
- [Changelog](https://github.com/hyperium/hyper/blob/master/CHANGELOG.md)
- [Commits](hyperium/hyper@v1.10.1...v1.11.1)

Updates `serde` from 1.0.228 to 1.0.229
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](serde-rs/serde@v1.0.228...v1.0.229)

Updates `serde_derive` from 1.0.228 to 1.0.229
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](serde-rs/serde@v1.0.228...v1.0.229)

Updates `hyper-util` from 0.1.20 to 0.1.21
- [Release notes](https://github.com/hyperium/hyper-util/releases)
- [Changelog](https://github.com/hyperium/hyper-util/blob/master/CHANGELOG.md)
- [Commits](hyperium/hyper-util@v0.1.20...v0.1.21)

Updates `hyper-rustls` from 0.27.9 to 0.27.10
- [Release notes](https://github.com/rustls/hyper-rustls/releases)
- [Commits](rustls/hyper-rustls@v/0.27.9...v/0.27.10)

Updates `which` from 8.0.5 to 8.0.6
- [Release notes](https://github.com/harryfei/which-rs/releases)
- [Changelog](https://github.com/harryfei/which-rs/blob/master/CHANGELOG.md)
- [Commits](harryfei/which-rs@8.0.5...8.0.6)

Updates `bollard` from 0.21.0 to 0.21.1
- [Release notes](https://github.com/fussybeaver/bollard/releases)
- [Changelog](https://github.com/fussybeaver/bollard/blob/master/RELEASE.md)
- [Commits](fussybeaver/bollard@v0.21.0...v0.21.1)

Updates `clap` from 4.6.2 to 4.6.7
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/main/CHANGELOG.md)
- [Commits](clap-rs/clap@clap_complete-v4.6.2...clap_complete-v4.6.7)

Updates `rustls-pki-types` from 1.15.0 to 1.15.1
- [Release notes](https://github.com/rustls/pki-types/releases)
- [Commits](rustls/pki-types@v/1.15.0...v/1.15.1)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-version: 1.0.151
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: tokio
  dependency-version: 1.53.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: tokio
  dependency-version: 1.53.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: anyhow
  dependency-version: 1.0.104
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: bytes
  dependency-version: 1.12.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: futures
  dependency-version: 0.3.34
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: futures-util
  dependency-version: 0.3.34
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: http
  dependency-version: 1.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: http-body
  dependency-version: 1.1.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: http-body-util
  dependency-version: 0.1.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: hyper
  dependency-version: 1.11.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: cc
  dependency-version: 1.5.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: tokio
  dependency-version: 1.53.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: prost
  dependency-version: 0.14.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: bitflags
  dependency-version: 2.13.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: bitflags
  dependency-version: 2.13.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: serde_json
  dependency-version: 1.0.151
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: tokio
  dependency-version: 1.53.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: futures
  dependency-version: 0.3.34
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: http-body-util
  dependency-version: 0.1.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: hyper
  dependency-version: 1.11.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: serde
  dependency-version: 1.0.229
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: serde_derive
  dependency-version: 1.0.229
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: hyper-util
  dependency-version: 0.1.21
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: hyper-rustls
  dependency-version: 0.27.10
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: which
  dependency-version: 8.0.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: bollard
  dependency-version: 0.21.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: clap
  dependency-version: 4.6.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: rustls-pki-types
  dependency-version: 1.15.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
The first Dependabot run did not group the otel crates. Dependabot keeps
a dependency only in its most specific group, and a group without
"patterns" scores higher than the pattern "opentelemetry*". So the
minor-and-patch group claimed opentelemetry, opentelemetry_sdk,
opentelemetry-otlp and opentelemetry-proto. Cargo treats 0.32 -> 0.33 as
a major update, so that group rejected them, and each crate fell
through to its own pull request. The first one,
freeunitorg#569, does not build: the
lock then holds two opentelemetry versions.

Exclude opentelemetry*, tonic* and prost* from minor-and-patch, so these
crates are only in the otel group, which has no update-types and moves
them together.

The run also showed that a group is one pull request for all
directories. Fix the comment that said otherwise. How
open-pull-requests-limit counts with several directories is not
clear: this run looked block-wide, while
dependabot/dependabot-core#10395 shows a
per-directory count for ungrouped updates. So put every version update
in a group: a new "major" group takes the major updates (including a
0.x minor, which cargo rates as major), with the same otel exclusion.
At most three version-update pull requests are then open either way,
and the limit is 3.

See updater/lib/dependabot/updater/pattern_specificity_calculator.rb and
common/lib/dependabot/dependency_group.rb in
https://github.com/dependabot/dependabot-core.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewed-by: Claude Fable 5.1 <noreply@anthropic.com>
Bumps the otel group with 4 updates in the /src/otel directory: [opentelemetry](https://github.com/open-telemetry/opentelemetry-rust), [opentelemetry_sdk](https://github.com/open-telemetry/opentelemetry-rust), [opentelemetry-otlp](https://github.com/open-telemetry/opentelemetry-rust) and [opentelemetry-semantic-conventions](https://github.com/open-telemetry/opentelemetry-rust).
Bumps the otel group with 1 update in the /test/fake_otlp directory: [opentelemetry-proto](https://github.com/open-telemetry/opentelemetry-rust).


Updates `opentelemetry` from 0.32.0 to 0.33.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-rust/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-rust/blob/opentelemetry-0.33.0/docs/release_0.33.md)
- [Commits](open-telemetry/opentelemetry-rust@opentelemetry-0.32.0...opentelemetry-0.33.0)

Updates `opentelemetry_sdk` from 0.32.1 to 0.33.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-rust/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-rust/blob/opentelemetry_sdk-0.33.0/docs/release_0.33.md)
- [Commits](open-telemetry/opentelemetry-rust@opentelemetry-semantic-conventions-0.32.1...opentelemetry_sdk-0.33.0)

Updates `opentelemetry-otlp` from 0.32.0 to 0.33.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-rust/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-rust/blob/opentelemetry-otlp-0.33.0/docs/release_0.33.md)
- [Commits](open-telemetry/opentelemetry-rust@opentelemetry-otlp-0.32.0...opentelemetry-otlp-0.33.0)

Updates `opentelemetry-semantic-conventions` from 0.32.0 to 0.33.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-rust/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-rust/blob/opentelemetry-semantic-conventions-0.33.0/docs/release_0.33.md)
- [Commits](open-telemetry/opentelemetry-rust@opentelemetry-semantic-conventions-0.32.0...opentelemetry-semantic-conventions-0.33.0)

Updates `opentelemetry-proto` from 0.32.0 to 0.33.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-rust/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-rust/blob/opentelemetry-proto-0.33.0/docs/release_0.33.md)
- [Commits](open-telemetry/opentelemetry-rust@opentelemetry-proto-0.32.0...opentelemetry-proto-0.33.0)

---
updated-dependencies:
- dependency-name: opentelemetry
  dependency-version: 0.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: otel
- dependency-name: opentelemetry_sdk
  dependency-version: 0.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: otel
- dependency-name: opentelemetry-otlp
  dependency-version: 0.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: otel
- dependency-name: opentelemetry-semantic-conventions
  dependency-version: 0.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: otel
- dependency-name: opentelemetry-proto
  dependency-version: 0.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: otel
...

Signed-off-by: dependabot[bot] <support@github.com>
1.37.0 is tagged. Changes merged from now on go into a new 1.37.1
block: the CHANGES header, a "unit" stanza in docs/changes.xml with no
entries yet (changes.dtd allows that), and the per-module stanza that
says "FreeUnit updated to 1.37.1". The date is the opening date; the
release commit sets the real one, as it did for 1.37.0.

The "version" file stays at 1.37.0 until the release commit. Until then
a build-deb dispatch on master sees 1.37.0 in "version" and 1.37.1 in
the top changes.xml stanza, as during the 1.36.2 period.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
auto/otel tested for OpenSSL on every system except macOS. Without
OpenSSL, configure stopped with "OpenTelemetry support requires
OpenSSL." With OpenSSL, configure added "-lssl -lcrypto" to the link
of unitd and to EXTRA_LIBS in unit.pc.

The test came with the first OTel build support in
nginx@9d3dcb8.
At that time, src/otel used reqwest 0.12.7 with its default features.
They include native-tls, and native-tls links openssl-sys.

freeunitorg@de24c38
removed native-tls and openssl-sys from src/otel/Cargo.lock. Since
1.36.0, the crate links no TLS stack. src/nxt_otel.c calls no OpenSSL
function. In src/otel, "cargo rustc --release -- --print
native-static-libs" prints "-lgcc_s -lutil -lrt -lpthread -lm -ldl
-lc".

The test was a leftover. It had two effects on a build with --otel
and without --openssl:

- On a host without the OpenSSL headers, configure failed.
- On a host with the headers, unitd got NEEDED entries for libssl and
  libcrypto when the linker kept unused libraries. On AlmaLinux 8
  (gcc 8.5.0), unitd needed libssl.so.1.1 and libcrypto.so.1.1.
  Application processes are forked from unitd, so they had these
  libraries loaded too. The gcc of Ubuntu 24.04 and Debian 13 passes
  --as-needed, so the entries do not appear there.

Now auto/otel defines NXT_HAVE_OTEL without a test. NXT_OTEL_LIBS is
empty on every system except macOS. The macOS libraries do not change.
On Linux, NXT_LIBM, NXT_LIBS and the compiler driver give the
libraries that the crate needs. The link succeeds without -lutil on
glibc 2.28 and 2.39.

The core job in build-test.yml now runs "./configure --otel" before
the real configure. The step fails if build/Makefile has -lssl or
-lcrypto. It reads the Makefile because the gcc of the runner passes
--as-needed, and readelf on unitd would not show the fault.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nxt_wasmtime_get_function_exports() looked up each configured handler
name with wasmtime_linker_get(). It checked only that the name existed,
and then read item.of.func for every kind of export. The worker later
called that value as a function. For a global or a memory, the value
holds no function reference, and Wasmtime does not define the call.
With Wasmtime 48.0.5 the worker died on signal 11 when the host called
the malloc handler.

The lookup now also checks that the kind is WASMTIME_EXTERN_FUNC. The
lookup of "memory" has checked WASMTIME_EXTERN_MEMORY in the same way
since freeunitorg#554. The worker logs
"module export (<name>) is not a function" and exits with code 1. The
router answers 503.

A new test sets the malloc handler to "__heap_base", a global, and to
"memory", a memory. Both exports are in the hello guest. On the old
code the worker died on signal 11, and the log line was missing.

This was found in the review of
freeunitorg#554 (comment).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guest can run code before the host serves a request.
wasmtime_linker_module() runs the start function of the guest, and
"_initialize" for a reactor. nxt_wasmtime_init_memory() calls the malloc
handler before it stores the memory handle. nxt_wasm_start() calls the
module_init hook before the first request.

In all of these, ctx->req is NULL. nxt_wasm_send_response(),
nxt_wasm_send_headers() and nxt_wasm_response_end() then crashed the
worker:

- Before the memory handle was set, send_response and send_headers
  passed a zeroed wasmtime_memory_t to wasmtime_memory_data(). Wasmtime
  48.0.5 panicked with "object used with the wrong store", and the
  worker died on signal 6.
- response_end called nxt_unit_request_done() with a NULL request, and
  the worker died on signal 11. In the module_init hook the prototype
  started a new worker after each crash: 204 "app process ... exited on
  signal 11" alerts in one test, and the request got no response.

These three imports now return a trap when ctx->req is NULL. The host
serves a request only after nxt_wasmtime_init() succeeds, so a request
also implies a memory handle. A trap in the start function,
"_initialize" or the malloc handler fails the startup, and the router
answers 503. A trap in a hook ends the hook, and the worker serves
requests as before.

Refusing a 64-bit memory before instantiation does not cover these
cases. A wasm32 guest reaches the same code, and response_end does not
use the memory.

The comment on nxt_wasmtime_update_baddr() now says that the base is
valid only until the guest runs again.

A new guest, test/wasm/noreq/noreq.c, is built without libc. It calls
one of the three imports from "_initialize", from a malloc handler or
from a module_init hook. clang has no attribute for the wasm start
section, so the test uses "_initialize", which runs in the same
wasmtime_linker_module() call. A hand-encoded module whose start
function is the import gave the same result for all three imports. Each
test fails on the old code, and it also fails when the check is removed
from the import that it calls.

These cases were found in the review of
freeunitorg#554 (comment).
ctx->req still keeps a finished request after the request ends. That is
not changed here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewed-by: Claude Fable 5.1 <noreply@anthropic.com>
Reviewed-by: DeepSeek V4.1 Flash
The controller reads <statedir>/version with nxt_int_parse().  That
function returns -1 for any byte that is not a digit.  On -1,
nxt_controller_prefork() logs "failed to restore previous
configuration: invalid version string" and drops conf.json, so unitd
starts with no configuration.

unitd writes the file with nxt_sprintf("%d") and no line end.  A file
written by hand usually has one: "echo 13700 > version" adds "\n", most
editors add a final "\n", and a file from Windows has "\r\n".  Each of
these lost the whole stored configuration.

The new nxt_controller_version_parse() skips trailing "\n", "\r", space
and tab, and then calls nxt_int_parse().  Any other byte that is not a
digit is still an error.  An empty file, or a file with only white
space, is still an error too.  The file is not rewritten on load.

The controller is the only reader of the version file.  The behaviour
dates from 1.26.0, which added the file.

Found in the review of
freeunitorg#586.

test/test_state_store.py seeds a state directory and starts unitd with
--restart.  With "13700\n", "13700\r\n" and "13700 \t\n" the stored
configuration now loads.  With "13700x\n", "", "\n", " 13700" and
"137\n00" unitd still logs the alert and restores nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With "chunked_transform", a chunked request body is read into a
temporary file. When a read ended right after the data of a chunk,
nxt_http_chunk_buffer() returned NXT_HTTP_CHUNK_END_ON_BORDER and left
in->mem.pos at the start of the data. The "between chunks" branch of
nxt_h1p_conn_request_body_read() keeps the bytes from pos to free for
the next read. So the data stayed in the buffer. The next read was
parsed after it, the parser found a data byte where the CRLF must be,
and the request got 400.

Now the border case moves in->mem.pos to in->mem.free. The data is
already linked into the output buffer, and the caller writes it to the
file before it compacts the read buffer.

freeunitorg#543

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
freeunitorg#587 added
nxt_controller_version_parse(). It strips trailing CR, LF, SP and HTAB
from the state version file, and then calls nxt_int_parse(). It has one
caller.

nxt_str_strip() in src/nxt_string.c already strips a line end, but it
had no callers. It had two defects:

- For an empty string it computed end - 1 before it compared the
  pointer with start. That pointer is before the buffer, which is
  undefined behavior.
- It did not strip SP or HTAB.

nxt_str_strip() now starts at end and stops at start, and it also strips
SP and HTAB. end is now const. The controller calls
nxt_int_parse() with the length from nxt_str_strip(), and
nxt_controller_version_parse() is removed. The behavior of the
controller does not change.

The string test in src/test/nxt_string_test.c gets seven nxt_str_strip()
cases. With the old body of nxt_str_strip() the test fails with
'nxt_str_strip("13700 \t\n") failed: got 7, expected 5'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewed-by: Claude Fable 5.1 <noreply@anthropic.com>
The port read handlers call nxt_fd_event_enable_read() when a read
returns EAGAIN. On epoll, enable_read queues an EPOLL_CTL_MOD even
when the read event is already active. So each drain of a port cost
one epoll_ctl call. Under keep-alive load the router made about 4 of
them per request.

An active read event stays registered. With the default edge-triggered
mode, the next datagram raises a new event. So the re-arm is needed
only when the event is not active. Read leaves the active state in
three places: nxt_port_read_close() makes it inactive,
nxt_fd_event_block_read() on a buffer allocation failure makes it
blocked, and the engine's level-triggered disable of a blocked read
makes it inactive. All three still take the enable path. App processes
use the libunit read loop, which does not call epoll_ctl, and are not
changed.

The ctrunc test now counts the enable_read calls of its stub engine,
and the stub leaves the event active as a real engine does. Each of
its three drains must make no call. The previous code makes one call
per drain and fails the test.

The router was traced with strace for 2000 keep-alive requests (oha
-c 1, external test app), two runs per build:
- epoll_ctl: 7998 and 7922 before, 2 and 2 after.
- epoll_wait: 10049 and 10077 before, 6288 and 6294 after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewed-by: DeepSeek V4.1 Flash
test_state_store_version_line_end checked the loaded configuration
with GET /config, then sent a request to the listener. GET /config can
answer before the router has applied the stored configuration and
bound the listener, so the request could fail with "Client can't
connect to the server." The test now waits for port 8080 first.

CHANGES and docs/changes.xml now say "The bug had appeared in 1.26.0.",
as the other entries do.

These are the review fixes for
freeunitorg#587, which was merged
before they were pushed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewed-by: Claude Fable 5.1 <noreply@anthropic.com>
…enabled

opentelemetry-otlp 0.33 retries a failed export up to 3 times by
default, with backoff from 100 ms to 1600 ms. Version 0.32 retried
only with the experimental-http-retry and experimental-grpc-retry
features, which FreeUnit does not enable. The update in
freeunitorg#571 (ccf1f52) turned the
retries on.

The batch worker blocks on each export. While it retries, later
batches wait in the queue. Set RetryPolicy::disabled() on the HTTP and
gRPC builders, so a batch is sent once, as in 1.37.0.

fake_otlp gets a --status option. It answers each export with that
HTTP status, or with UNAVAILABLE for gRPC, and still counts and dumps
the request. test_otel_export_not_retried uses it with 503 and checks
one request per failed batch. On the previous code it fails with
"4 export requests for 1 failed batches" for http and grpc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewed-by: Claude Fable 5.1 <noreply@anthropic.com>
The h1proto field nbuffers was a uint8_t. It counts the large buffers
of a request header and is compared with the size_t setting
"large_header_buffers". After 255 buffers the count went back to 0.
With "large_header_buffers" set to 256 or more, the limit never fired.

The parser rewinds only to the start of an incomplete field. So a
header made of many short fields takes a new large buffer every few
fields, and each buffer stays allocated until the request ends. With
the limit off, the memory of such a header was bounded only by
"header_read_timeout". Only an administrator can set the value.

The counter is now a size_t, the type of the setting. It stops at the
limit, so it cannot wrap first. nxt_h1proto_t grows from 704 to 712
bytes on x86_64 because of padding after the field. The 8 bytes per
connection do not matter. A uint32_t would avoid the padding, but a
limit above 2^32 - 1 would then depend on memory running out first.
The setting is not capped at 255.

The setting became valid in the configuration in 1.29.0. Before that,
the validator rejected it, and the router used its default of 4.

Found while reviewing
freeunitorg#583.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewed-by: Claude Fable 5.1 <noreply@anthropic.com>
The descriptor check compared only counts, so a failure said
"descriptors leak router" and nothing about what leaked.  The
Alpine aarch64 build runs with --fds-threshold=160 and nginx#1129 is
still open because nobody could tell which descriptors they were.

Each baseline now also records the kinds behind the count, read
from /proc/<pid>/fd: pipe, memfd, the anon_inode name (eventfd,
signalfd, eventpoll, io_uring), the file path, and for sockets
the protocol found by inode in /proc/<pid>/net: "tcp listen",
"tcp close-wait", "udp6", "netlink", "unix" or "unix:<path>".
Kernel autobind names are folded into "unix:@autoBind" so that
equal sockets add up.  A failing assert lists what changed:

    descriptors leak router: eventfd +1, unix +1

The threshold and the counting are unchanged.  Without /proc the
message says so.

Co-Authored-By: exo-free
UnicodeDecodeError from read_text on /proc/net/unix crashed teardown
when a socket path had non-UTF-8 bytes; unix paths with spaces were
truncated by line.split().  Read bytes and decode with backslashreplace,
and split unix lines with maxsplit=7 so the path survives spaces.

Co-Authored-By: exo-free
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T00:16:52.002005Z cee5ceb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@andypost

andypost commented Oct 8, 2026

Copy link
Copy Markdown
Owner Author

Superseded by freeunitorg#622 — this fork is a stale mirror of the archived nginx/unit, so the compare against its old master showed 250 commits.

@andypost andypost closed this Oct 8, 2026
@andypost
andypost deleted the test/fd-leak-attribution branch October 8, 2026 12:22
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