Skip to content

actix: unwind on panic, so one oversized header name no longer kills the server - #1851

Merged
MDA2AV merged 2 commits into
mainfrom
actix-spec-crash
Nov 22, 2026
Merged

MDA2AV merged 2 commits into
mainfrom
actix-spec-crash

Conversation

@MDA2AV

@MDA2AV MDA2AV commented Nov 22, 2026

Copy link
Copy Markdown
Owner

actix's H/1.1 compliance score is saved as a crash (120/159, from #1782's run): the server died partway through Http11Probe. This PR finds the cause and fixes it. It also covers CON-1M and CON-1M-TLS, which actix already subscribes to but has no results for.

The crash

The job log of the run that saved the score shows the panic, followed by exit 139:

thread 'actix-rt|system:0|arbiter:37' (44) panicked at .../actix-http-3.20.0/src/h1/decoder.rs:93:83:
called `Result::unwrap()` on an `Err` value: InvalidHeaderName

MAL-LONG-HEADER-NAME sends one request with a 100,000-byte header name. httparse accepts it: every byte is a token character, and the request fits in actix-http's 128 KiB head buffer. actix-http then builds each name with HeaderName::from_bytes(..).unwrap(), and http refuses names longer than 65,535 bytes. Because the entry built with panic = "abort", that one request ended the process, and the 23 tests after it all failed with "Failed to connect". The test itself was scored as a pass, because the connection closed.

The unwrap() is still on actix-web's main, so no actix-http release fixes it.

The fix

This drops panic = "abort" from [profile.release], which leaves Rust's default, unwind. actix-server runs each connection as its own task, and tokio catches a panic inside a task. Now the request only costs its own connection, and the worker keeps running. Any actix-web app built with the default profile already behaves this way.

The complete fix is a 400 response. That needs actix-http to map the error to ParseError::Header instead of unwrapping it, which is a change to actix-web itself, not to this entry.

Checked on the dev box

main (abort) this PR
one request with a 100 KB header name server exits (139), same panic connection closed, server keeps serving
Http11Probe d50d818 (h1) 120/159, crashed (saved) 143/159, no crash
h2spec 2.6.0 (h2) 145/145 (saved) 143/145
validate.sh actix 114 passed, 0 failed
  • h1: the 23 tests that could not connect now run, and all 23 pass. Nothing that passed before fails now. The 16 tests that still fail were failing before as well: Host header validation (4), asterisk-form targets and CONNECT (3), chunk-extension and trailer syntax (4), 408 on an incomplete or empty request (2), a 100 KB header value and a 100 KB method that get an answer instead of a rejection (2), and a POST WebSocket upgrade that gets no response (1).
  • h2: http2/5.1/8 and http2/6.9.1/3 race the server's response against the client's next frame. On the dev box they also fail intermittently with main's image (one of the two failed in each of 6 runs), so the failures come from timing, not from this change. The bench host passed both.

CON-1M and CON-1M-TLS

actix has subscribed to both since #1815, which also raised its connection cap to max_connections(100_000) per worker. No run has saved a row for it yet, because #1843 saved genhttp-ioxide only. Nothing else is needed. Both listeners bind 0.0.0.0: validation reached them on 127.0.0.2 and 127.0.0.32, with :8081 over TLS 1.3. actix's 5 s keep-alive and first-request timeouts are longer than the 4 s pacing. connections-5m stays listed but is skipped, because actix is not on its allowlist.

The panic strategy changes codegen for the whole binary. A full run with --save on this PR would refresh every actix row, save the spec scores, and add CON-1M and CON-1M-TLS. I took no performance numbers on the dev box.

🤖 Generated with Claude Code

…the server

Http11Probe's MAL-LONG-HEADER-NAME sends a 100,000-byte header name.
httparse accepts it, actix-http 3.20 unwraps HeaderName::from_bytes(),
which refuses names over 65,535 bytes, and with panic = "abort" that one
request ended the process (exit 139): the h1 suite was saved as crashed,
120/159, with the 23 tests after it failing to connect.

Dropping panic = "abort" leaves the default, unwind. Every connection is
its own task, so tokio catches the panic and only that connection is
dropped. Locally the suite now completes, 143/159.
@MDA2AV

MDA2AV commented Nov 22, 2026

Copy link
Copy Markdown
Owner Author

/benchmark --save

@github-actions

Copy link
Copy Markdown
Contributor

👋 Benchmark request received. A collaborator will review and approve the run.

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Results

Framework: actix | Test: all tests

Test Conn RPS Rate CPU/req p99 p99.9 CPU Mem Δ RPS Δ Mem
baseline 4096 2,905,625 — — — — 6338.4% 384MiB -1.7% +3.5%
pipelined 4096 18,763,571 — — — — 6435.4% 400MiB -0.8% -6.5%
limited-conn 4096 1,144,727 — — — — 4582.3% 298MiB +0.5% +7.2%
json-comp 4096 586,605 — — — — 6584.8% 619MiB -4.4% +1.6%
json-comp 16384 573,534 — — — — 6613.4% 1016MiB -3.5% +11.6%
json-tls 4096 1,346,577 — — — — 6341.8% 434MiB -3.9% +1.2%
8gbit 512 49,351 0.9870 48.90us 120.0us 5410.0us 241.7% 340MiB ~0% +1.2%
static-tls 1024 413,864 — — — — 6297.3% 2.7GiB -0.2% +3.8%
async-db 1024 324,684 — — — — 3206.1% 250MiB -3.2% +7.3%
fortunes 1024 184,341 — — — — 3258.5% 272MiB -1.2% +2.6%
baseline-h2 256 6,207,410 — — — — 6419.4% 548MiB -3.4% +6.8%
baseline-h2 1024 4,722,351 — — — — 6254.4% 838MiB -2.4% +1.1%
static-h2 256 422,892 — — — — 6239.4% 2.3GiB +0.7% ~0%
static-h2 1024 402,279 — — — — 6251.9% 2.8GiB -0.5% ~0%
latency-1m 1024 998,026 0.9980 25.70us 187.0us 2279.0us 2810.8% 302MiB ~0% +2.7%
latency-10k 1024 9,981 0.9981 27.84us 107.0us 171.0us 26.6% 300MiB ~0% -16.7%
async 32000 2,014,158 — — — — 4487.8% 1.1GiB +0.8% -15.4%
connections-1m-tls 1000000 249,969 0.9999 38.63us 110.0us 149.0us 1449.6% 32.0GiB NEW NEW
connections-1m 1000000 250,001 1.0000 33.78us 136.0us 189.0us 854.5% 22.6GiB NEW NEW

Composite score, main against this run, in the board's default view:

Family main this run Δ
HTTP/1.1 6121.3 (13 of 112) 7690.3 (6 of 112) +1569.1
HTTP/2 1865.6 (9 of 41) 1853.3 (9 of 41) -12.2
WebSocket 2200.2 (12 of 39) 2200.2 (12 of 39) +0.0
Database 1782.8 (4 of 6) 1743.0 (4 of 6) -39.7

The results on main were measured in another session, so a few points up or down can be the machine and not the change.

Compliance

Suite Tool Score Failed
H/1.1 (h1) http11probe d50d818 143 / 159 16
H/2 (h2) h2spec 2.6.0 144 / 145 1
H/1.1: 16 failed
Test Expected Got
COMP-HOST-WITH-USERINFO Host header with userinfo (user@host) must be rejected (RFC 9112 §3.2, MUST) 400 or close 200, connection left open
COMP-HOST-WITH-PATH Host header with path component must be rejected (RFC 9112 §3.2, MUST) 400 or close 200, connection left open
COMP-ASTERISK-WITH-GET Asterisk-form (*) request-target with GET must be rejected (RFC 9112 §3.2.4, MUST) 400, close, or timeout = warn 404, connection left open
COMP-OPTIONS-STAR OPTIONS * is the only valid asterisk-form request (RFC 9112 §3.2.4, MUST) 2xx or 405; close/timeout = warn 404, connection left open
COMP-METHOD-CONNECT CONNECT to an origin server must be rejected (RFC 9110 §9.3.6, SHOULD) 400/405/501 or close 404, connection closed
COMP-HOST-EMPTY-VALUE Empty Host header value must be rejected (RFC 9112 §3.2, MUST) 400 or close 200, connection left open
SMUG-CHUNK-BARE-SEMICOLON Chunk size with bare semicolon and no extension name must be rejected (RFC 9112 §7.1.1, MUST) 400 or close 200, connection left open
SMUG-CHUNK-EXT-INVALID-TOKEN Chunk extension with invalid token character must be rejected (RFC 9112 §7.1.1, MUST) 400 or close 200, connection left open
SMUG-CHUNK-SIZE-TRAILING-OWS Chunk size with trailing whitespace before CRLF must be rejected (RFC 9112 §7.1, MUST) 400 or close 200, connection left open
SMUG-CHUNK-LF-TRAILER Bare LF in chunked trailer termination — server MAY accept bare LF per RFC 9112 §2.2 (RFC 9112 §7.1, MAY) 400 or 2xx no response, timed out
SMUG-MULTIPLE-HOST-COMMA Host header with comma-separated values must be rejected (RFC 9110 §7.2, MUST) 400 or close 200, connection left open
MAL-LONG-HEADER-VALUE 100KB header value should be rejected with 431 (SHOULD) 400/431 or close 200, connection left open
MAL-INCOMPLETE-REQUEST Partial HTTP request — request-line and headers but no final CRLF (NOTAPPLICABLE) 400/close/timeout 408, timed out
MAL-EMPTY-REQUEST Zero bytes — TCP connection established without sending any data (NOTAPPLICABLE) 400/close/timeout 408, timed out
MAL-LONG-METHOD 100KB method name should be rejected (SHOULD) 400, 501 or close 405, connection left open
WS-UPGRADE-POST WebSocket upgrade via POST must not be accepted (RFC 6455 §4.1, MUST) !101 no response, timed out
H/2: 1 failed
Test Expected Got
http2/5.1/8 closed: Sends a DATA frame after sending RST_STREAM frame GOAWAY Frame (Error Code: STREAM_CLOSED) or RST_STREAM Frame (Error Code: STREAM_CLOSED) or Connection closed DATA Frame (length:0, flags:0x01, stream_id:1)
Full log
    "rate": 7813,
    "launched": 31250,
    "window_requests": 156256,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.16",
    "connections": 31250,
    "rate": 7813,
    "launched": 31250,
    "window_requests": 156255,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.17",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156239,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.18",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156239,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.19",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156236,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.20",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156237,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.21",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156244,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.22",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156244,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.23",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156244,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.24",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156231,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.25",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156236,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.26",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156233,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.27",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156238,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.28",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156243,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.29",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156244,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.30",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156239,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.31",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156245,
    "window_s": 20.0
   },
   {
    "addr": "127.0.0.32",
    "connections": 31250,
    "rate": 7812,
    "launched": 31250,
    "window_requests": 156239,
    "window_s": 20.0
   }
  ]
 },
 "connections": 1000000,
 "launched": 1000000,
 "connections_open": 1000000,
 "duration_s": 20.0,
 "requests": 4999980,
 "bytes": 509997960,
 "achieved_rate": 249999.0,
 "target_rate": 250000,
 "rate_ratio": 1.0,
 "bytes_per_sec": 25499898.0,
 "max_schedule_lag_us": 0,
 "server_cpu_usec": 169564947,
 "latency_us": {
  "min": 32,
  "mean": 75.5,
  "max": 1323,
  "p50": 72,
  "p75": 84,
  "p90": 99,
  "p99": 138,
  "p99_9": 190,
  "p99_99": 707
 },
 "status_codes": {
  "1xx": 0,
  "2xx": 4999980,
  "3xx": 0,
  "4xx": 69,
  "5xx": 0
 },
 "errors": {
  "connect": 0,
  "read": 0,
  "write": 0,
  "timeout": 0,
  "deadline": 0,
  "non_2xx_3xx": 0
 },
 "ramp_connect_errors": 0
}
[info] CPU 803.9% | Mem 22.6GiB
[info] run 1 wins on score

=== Best: 250001 req/s (CPU: 854.5%, Mem: 22.6GiB) ===
[info] exact CPU: 168.90 core-seconds | 33.779 us/req
=== Fixed-rate: cpu/req 33.78us | p99 136.0us | p99.9 189.0us | rate_ratio 1.0000 ===
=== Connections: 1000000 open of 1000000 | connect errors in the window 0 ===
[info] saved results/connections-1m/1000000/actix.json
httparena-bench-actix
httparena-bench-actix
[info] rebuilding site/data/*.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/frameworks.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/results/actix.json - 19 new, 33 total
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/current.json
[info] done
httparena-postgres
[info] restoring loopback MTU to 65536

@MDA2AV
MDA2AV merged commit 2647240 into main Nov 22, 2026
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.

1 participant