Opened 3 days ago
Last modified 3 days ago
#451 new defect
mlsys_mailer_deliver_.pl1 delivery timeout is way too long for modern network connections
| Reported by: | Jim Lippard | Owned by: | Eric Swenson |
|---|---|---|---|
| Priority: | minor | Milestone: | MR12.10 |
| Component: | Networking | Version: | MR12.9 |
| Keywords: | mlsys, mlsys_mailer_deliver_.pl1 | Cc: |
Description
While tracking down the cause of a hang and CPU spin while attempting and failing to send network mail over Chaosnet (see ticket #448, which I believe accounts for the CPU spin but not the hang), I next turned to mlsys_mailer_deliver_.pl1. This module is the per-host delivery driver: it obtains the service list for a host and calls each delivery module available in turn under a timeout which is the only one anywhere in the delivery path (this module → nit_ → mmd_chaos_ → mgp_io_). The timeout is a transmission rate allowance of 300 s plus 112 ms per character of the message (lines 62–63), a figure dating to 1970s dialup line speeds rather than to anything about reachability: a 200-character message gets 322 s, a 5,000-character one 860 s, a 10,000-character one 1,420 s. I ran into this with short test messages, which produced 322–326 second delivery attempts for 196–232 character messages. On expiration the module does a non-local goto out of punt_dproc that bypasses the handler teardown at lines 141–143. So the timeout neither measures the right quantity nor reliably ends the attempt — the goto unwinds through mmd_chaos_'s cleanup handler into an iox_$close that can block without bound. That last part has no fix available in this module: it has no handle on the dproc's blocked I/O, and the goto is itself what triggers the hanging close. That will be covered in a separate ticket on mgp_io_.pl1.
Change History (2)
comment:1 by , 3 days ago
| Milestone: | MR12.9 → MR12.10 |
|---|
comment:2 by , 3 days ago
- the bypassed teardown is an issue that should be fixed: punt_dproc's goto got_error (175 → 145) skips lines 141–143: revert io_error, timer_manager_$reset_alarm_call, and revert cleanup. Both handlers consequently remain established for the remainder of the procedure, across the recipient loop at 151–162 and the free at 164, when they should have been reverted. The surviving cleanup handler is harmless, since it resets an alarm that has already fired; the surviving io_error handler is a live hazard only if anything can signal io_error, which brings up the next item. The alarm itself is not leaked on this path — it has fired by definition — so this is a correctness-by-inspection item with no observed consequence today.
- The io_error handler records a zero status code — latent
The handler at 133–138 sets code = 0 before jumping to got_error, so first_code at 146 is left at zero and the recipient is stamped at 158 with code = first_code (0) and result = "I/O error." — a delivery failure carrying the no-error status value, which is what mlsys_mailer_unspool reads to decide fatal versus retry. The handler should preserve the dproc's code, or substitute a specific nonzero error if the dproc did not set one.
This is latent: io_error is not signalled anywhere in the Chaos path — the only three occurrences in mlsys_mailer_deliver_, nit_, mmd_chaos_ and mgp_io_ are this module's own declaration, handler and revert. It needs checking against mmd_tcp_smtp_ and mlsys_mailer_deliver_local_, which I have not read. If either signals it, this item and item 1 both become live.
- service_list is not freed on the cleanup path
The on cleanup at 132 resets the alarm and does nothing else. The service_list allocated by nit_$get_service_list at 120 lives in the process's system free area and is not freed, so any unwind of this procedure from outside — a QUIT plus release, or an unhandled fault below it — leaks it. This is the same hole that NET063 (2026-09-29) closed on the queue_only return path at 122–124; the cleanup handler is what remains.
Found by inspection, and not reproducibly testable: punt_dproc's goto is within this procedure's block, so it never exits it and this handler does not run on a timeout. The handler runs only on an asynchronous unwind, which cannot be scheduled at a known point. The fix is the one-line free that line 164 already performs.
This ticket and #452 in mgp_io_.pl1 (also implicating mmd_chaos_.pl1) should all be fixed together. The timeout belongs in mgp_io_, mmd_chaos_ needs to use it. The 300-second timeout here was compensating for a lower layer that doesn't time out, and implementing that compensation as a non-local goto through the network code is what caused the hang. The timeout value in this module should be a short timeout for the connection establishment, distinct from the transmission allowance based on message size.

Inadvertently set Milestone to MR12.9, should be MR12.10.