Opened 3 days ago
Last modified 3 days ago
#452 new defect
mgp_io_.pl1 can hang while attempting and failing to send network mail over Chaosnet
| Reported by: | Jim Lippard | Owned by: | Eric Swenson |
|---|---|---|---|
| Priority: | major | Milestone: | MR12.10 |
| Component: | Networking | Version: | MR12.9 |
| Keywords: | mlsys, networking, mgp_io_.pl1, Chaosneet | Cc: |
Description
While tracking down a hang while attempting and failing to send network mail over Chaosnet (see #448 and #451), the hang itself turned out to be here. The -timeout attach option covers only connection establishment: get_timeout (158–175) stores the value, line 185 arms timer_manager_$alarm_wakeup immediately before the connect, and check_connection_loop (196–208) is the only ipc_$block in the module that tests my_event_wait_info.message against ALARM_ and turns it into error_table_$net_timeout. Line 210 resets the alarm on success and the option is never consulted again. Every subsequent blocking operation — put_chars (399), get_chars (434), get_line (476), position (527), read_record/read_length (570), write_record (598), and the "eof" control order's acknowledgement wait (717) — is guarded only by attach_data.no_block and can wait indefinitely. mgp_io_$mgp_io_close reaches line 598 through the EOF write at 351, so even an orderly close of a connection whose peer has gone silent without a CLS never returns. The alarm channel is already in attach_data.wait_list, so a wakeup does break these blocks — the defect is that only one of the eight sites inspects the message.
I hit this with a partially-up Chaosnet connection that wasn't quite working, so it may be difficult to reproduce. The path must be silently discarded, not refused: if the RFC is never answered the attempt dies in mgp_io_$mgp_io_attach, whose own cleanup handler (line 14) nulls the iocb pointers at 111 before mmd_chaos_'s handler runs, so the close never enters this module; and if the peer sends a proper CLS, check_for_disconnect (840) exits cleanly. The hang needs the Chaos layer to still believe the connection is open while having no output window.
io_call attach x mgp_io_ ghm -server mail
io_call open x stream_input_output — confirm the greeting arrives
drop the path at cbridge, or with an IP filter rule that silently discards the traffic
io_call close x
Step 4 should never return, with no CPU accumulating — compare relative CPU in the ready message before and after, which also distinguishes this from #448.
Change History (2)
comment:1 by , 3 days ago
comment:2 by , 3 days ago
Also one formatting issue in the current code that could mislead future work:
Lines 308–311 in mgp_io_$mgp_io_detach: the else at 311 is indented as though it binds to the outer if at 308, but PL/I binds it to the inner if at 309, which is what's intended. Compare attach_clean_up at 103–106, which is the same construct indented correctly.

I typoed the keyword "Chaosnet" as "Chaosneet". There are additional defects identified in this module related to this issue, including the root cause: A. The timeout value isn't retained anywhere (root cause)
timeout is declared at line 953 as plain automatic storage and is not a member of attach_data (1010–1035). It is set during mgp_io_$mgp_io_attach and ceases to exist when that entry returns — attach_clean_up can read it at line 107 only because it runs in the same activation. No later entry can see it. So the option is not merely unused by the I/O paths; the value is unavailable to them. Any fix to the seven unbounded sites requires a timeout field in attach_data alongside no_block, which has 25 bits of padding available at 1026.
The ioa_$rsnnl at 211–216 rebuilds attach_data.attach_description with -network, -server, -device, -no_block and -privileged, and omits -timeout. The switch therefore misreports how it was attached, and anything that re-attaches from the stored description silently loses the option.
on any_other call process_terminator is established at 74 (attach), 275 (open), 319 (detach) and 358 (close) to make the iocb surgery atomic. But any_other catches cleanup, a routine condition raised whenever a caller unwinds — which is exactly what mlsys_mailer_deliver_ does on every delivery timeout (#451). In those windows there is no on cleanup to take precedence, so an unwind through them calls terminate_process_ ("fatal_error"). The windows are narrow — all four sit after the blocking work and contain only local assignment plus iox_$propagate — so this is probably not what I observed, but making a routine condition fatal is wrong regardless. Each should be paired with an on cleanup that resets the IPS mask and resignals.
With timeout = -1 (the default, line 22) no alarm is armed at 185, so check_connection_loop (196–208) re-polls mgp_user_$check_connect on every event-channel wakeup with no bound and no exit. If Chaosnet is retransmitting an unanswered RFC and signalling the channel on each attempt, this becomes a poll loop that consumes CPU at the retransmit rate and never terminates. I have not confirmed this is the spin I saw — #448's re-probe cadence remains the likelier explanation — but it is a second candidate in the same episode and should be ruled in or out.
mmd_chaos_ passes neither -timeout nor -no_block in either attach description — "mgp_io_ a -server mail" (line 183) and "mgp_io_ a -server ""send a"" -network chaos" (line 141) — so both mail connections run fully blocking with no bound. Once this module can honour a timeout on I/O operations, mmd_chaos_ has to actually request one, or the fix lands without protecting the mail path.