Repository navigation
Replies: 6 comments
A search of Debian BTS turned up #330842, "minicom doesn't handle EOF & I/O errors well" (open since 2005-09-30, tagged upstream, no patches): https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=330842 It's the same class of bug — minicom busy-looping when a device fd returns I/O errors — but a different code path: that report covers I also scanned the salsa upstream tracker (https://salsa.debian.org/minicom-team/minicom/-/issues) and didn't find an existing report for either symptom in the open or closed sets. |
Update: bisect range narrowed@andy5995 just successfully completed the same ZModem upload that triggered the runaway twice before, on The Manjaro host that previously hit the runaway twice on the same BBS is running minicom 2.11.1 (May 2026 build). The Arch package itself only carries one patch — Both patches only touch the read-side ( Updated picture
So the working hypothesis is now: regression introduced in upstream minicom somewhere between 2.8 and 2.11.1, in code outside the Reproducer summary for upstreamFor convenience if someone files this against salsa:
@andy5995 may file this upstream at https://salsa.debian.org/minicom-team/minicom now that the bisect range is concrete. |
Smoking gun locatedReading void mc_wflush(void)
{
int todo, done;
todo = _bufpos - _bufstart;
_bufpos = _bufstart;
while (todo > 0) {
done = write(1, _bufpos, todo);
if (done > 0) {
todo -= done;
_bufpos += done;
}
if (done < 0 && errno != EINTR)
break;
}
_bufpos = _bufstart;
}Two issues compound:
Three fix angles (for the upstream maintainer to choose from)A. Detect-and-exit inside if (done < 0 && errno != EINTR) {
if (errno == EIO || errno == EPIPE || errno == EBADF)
exit(1); /* controlling terminal is gone; atexit runs lockfile cleanup */
break;
}Stops the runaway on the first failed B. Make C. Sticky global "output dead" flag set by Of the three I'd suggest A for an upstream MR — it's small, obviously correct, and addresses the strace symptom directly. B would be the right shape if upstream wants to refactor in the same direction. C is the least clean. @andy5995 has a |
|
I filed an issue at minicom-team/minicom#19 which basically just links back here. |
Updated diagnosis — earlier
|
| Time | PID | Event |
|---|---|---|
| 17:25:15.367 | 3032919 | minicom reads 0x18 (CAN) from fd 0 (user typed) and writes it to fd 4 (PTY/modem) |
| 17:25:15.527 | 3032919 | another 0x18 to BBS — two CANs is the ZModem CANCEL prefix |
| 17:25:15.594 | 3032919 | SIGCHLD from PID 3033010, exit status 1, utime 0.10s, stime 0.17s — a forked child failed quickly |
| 17:25:15.594 | 3032919 | minicom reads BBS-side message: "script \"arcadia.sh\": global timeout" (37 bytes) |
| 17:25:15.595 | 3032919 | minicom echoes the 37 bytes one byte at a time to fd 1 — dirflush=1 mode |
| 17:25:15.596 | 3032919 | POLLHUP revent on fd 5 (PTY slave / modem read side) — unusual |
| 17:25:21.631 | 3032919 | user pressed Esc (~6s after the SIGCHLD) |
| 17:25:22.014 | 3032919 | user pressed Z — meta+Z opens minicom's command menu |
| 17:25:22.015 | 3032919 | menu renders (one 2048-byte chunk + one 240-byte tail to fd 1) |
| 17:25:22.015 | 3032919 | user pressed U (selects "Add Carriage Ret" toggle) |
| 17:25:22→17:25:24 | — | ~2.7-second gap with no syscalls of interest |
| 17:25:24.751 | 3032919 | runaway begins — 2048-byte writes back-to-back to fd 1, no polls, no reads, ~50µs apart |
Runaway sample — last 6 lines of the trace
3032919 17:25:36.069060 write(1, "[0m\33[10m\33[32;40m \33[0m\33[10m\33[30;4"..., 2048) = 2048
3032919 17:25:36.069109 write(1, "\33[32;40m \33[0m\33[10m\33[30;40m\33[1m\333\33"..., 2048) = 2048
3032919 17:25:36.069154 write(1, " \33[0m\33[10m\33[30;40m\33[1m\333\33[0m\33[10m"..., 2048) = 2048
3032919 17:25:36.069198 write(1, "0m\33[30;40m\33[1m\333\33[0m\33[10m\33[32;40m"..., 2048) = 2048
3032919 17:25:36.069242 write(1, "0m\33[1m\333\33[0m\33[10m\33[32;40m \33[0m\33[1"..., 2048) = 2048
3032919 17:25:36.069286 write(1, "[0m\33[10m\33[32;40m \33[0m\33[10m\33[30;4"..., 2048 <detached ...>
Every write succeeds (= 2048), no errors. ~50 µs between writes → ~20,000 writes/sec. The buffer content is ANSI styling sequences interleaved with \333 (0xDB = code-page-437 full block; this is minicom rendering full-block characters for window decoration). The buffer is the same 2048 bytes on every iteration.
What this evidence rules in / out
- Not
mc_wflush()busy-looping on EIO — every write returns= 2048clean. My earlierexit(1)patch can never fire here. - Not
help()/wxgetch()— those would showread()from fd 0 in the trace; we see zero during the runaway window. - The render loop is upstream of
mc_wflush— somewhere a caller keeps refilling the screen buffer with the same content and re-flushing, never yielding to wait for input. ~20k iterations/sec is consistent with a pure CPU loop that never reachesselect/poll/read.
Possible cascade — speculative, not proven
The presence of SIGCHLD (status 1, exit code from a child that ran for ~270 ms) plus POLLHUP on fd 5 plus a later meta-key interaction plus a 2.7-second pre-runaway lull all bunched together makes me suspect — but I do NOT have proof — that:
- The BBS emitted bytes that minicom's auto-ZModem detector treated as a
ZRQINIT(the**\x18B0100000023be50prefix is exactly the ZModem ZRQINIT framing). - minicom auto-forked
rz(orsz); the child exited status 1 (no real ZModem session to consume) → SIGCHLD. - The SIGCHLD handler / post-child cleanup left some flag in an inconsistent state (e.g. a "screen needs redraw" sticky bit; the
POLLHUPon fd 5 may be related). - The user's subsequent menu interaction (Esc+Z → menu render → U → "Add Carriage Ret" toggle → status_set_display) was the immediate seed for the runaway, but the underlying condition that prevents the redraw flag from being cleared is what makes the loop infinite.
@andy5995 has reproduced the runaway in other situations too — including on bbs.f4fbbs.com:2323 (also Mystic) the first time he used the meta key at a menu, with no ZModem activity involved. So the SIGCHLD/ZModem chain above can't be a necessary precondition. There is at least one other path into the same end state.
What we'd want from upstream
This is a separate bug from the one the orphan-terminal patch addresses. Suggested places to look:
- The
do_terminal()main loop insrc/main.c— is there a redraw-trigger flag set somewhere that never gets cleared after the main loop services it? - The
case 'z': … case 'u': …dispatch insrc/minicom.cafterdirty_goto:— does any path leave a follow-up "redraw needed" condition true? - SIGCHLD handling (anywhere
SIGCHLDissignal()d orsigaction'd). If a handler setsdirty/redraw/ similar, does it always get cleared after one pass through the main loop? mc_wclose()of a transient window when the underlying state has changed — restore-from-saved-state behavior when the screen was repainted by a child process.
I'm not in a position to write a confident fix; the runaway is reproducible but my coverage of minicom's redraw-trigger surface is shallow. If anyone closer to the codebase has a hypothesis, this strace should give enough context to test it.
Status on the wflush patch
The orphan-terminal EIO patch I proposed earlier is still a valid (and small) defense-in-depth improvement — when stdout does die, mc_wflush shouldn't silently throw away the error. But it is not the fix for the bug @andy5995 hits day-to-day, and we should not pretend it is. The Arch PKGBUILD that briefly carried that patch has had it removed for testing.
Patch attempt — appears to fix the live-runaway caseAfter the strace evidence in the previous comment, I wrote the patch below (via a subagent walking the rendering code paths in minicom). @andy5995 did not author any of the source change — his role was applying the patch to a local salsa worktree, rebuilding, and testing under the same BBS conditions. Live-test results follow. Proposed root causeThree loops in
PatchAuthored by Claude (Opus 4.7); not by @andy5995. diff --git a/src/window.c b/src/window.c
@@ -621,12 +621,16 @@ void mc_wclose(WIN *win, int replace)
g = gmap + (y * stdwin->xs);
for (x = 0 ; x < win->x1;) {
cwidth = _write(g->value, 1, x, y, g->attr, g->color);
+ if (cwidth < 1)
+ cwidth = 1; /* control/zero-width stored in gmap; avoid infinite loop */
x += cwidth;
g += cwidth;
}
/* to here */
for (x = win->x1; x <= win->x2;) {
cwidth = _write(e->value, 1, x, y, e->attr, e->color);
+ if (cwidth < 1)
+ cwidth = 1; /* control/zero-width stored in window map; avoid infinite loop */
x += cwidth;
e += cwidth;
}
@@ -735,6 +739,8 @@ void mc_wredraw(WIN *w, int newdirect)
for (y = miny; y <= maxy; y++) {
for(x = minx; x <= maxx; ) {
cwidth = _write(e->value, -1, x, y, e->attr, e->color);
+ if (cwidth < 1)
+ cwidth = 1; /* control/zero-width stored in gmap; avoid infinite loop */
x += cwidth;
e += cwidth;
}Stop-the-bleeding fix: the loops advance at least one cell per iteration. A cleaner root-cause fix would refuse to store cells with Live-test results@andy5995 rebuilt the salsa worktree with this patch and exercised it against the same Arcadia BBS that triggered the original runaway:
Side observation: failed upload had a separate causeInitial post-patch upload attempts also failed (status window opened, vanished, no transfer). The strace showed minicom forking bare ConfidenceReasonably high. The mechanism is concrete, matches the strace fingerprint precisely (user-space-only loop, 2048-byte flushes of CP437 full-block sequences after child-process termination that emitted binary), and the live-test signal is consistent across runaway, transfer, and menu scenarios. Caveat: the proposed precondition — a control byte landing in StatusCommitted on a salsa branch and submitted upstream: MR https://salsa.debian.org/minicom-team/minicom/-/merge_requests/28. Available for follow-up here on the loop-guard vs root-cause-fix question ( |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Symptom
While testing modemu2k v0.2.0 / v0.2.1-in-progress against real BBS systems through minicom, @andy5995 hit a "runaway characters" flood twice:
Later, a third repro happened without any BBS connection at all: @andy5995 attempted to close minicom (Esc+Z), the xfce-terminal window died (taking modemu2k with it), and minicom was left orphaned and still spinning.
pkill minicom(SIGTERM) had no effect; only SIGKILL stopped it.Diagnosis
The third repro produced clean evidence. The
/procstate andstraceof the orphaned minicom showed:State: R (running)andwchan: 0— burning a core in userspace, not blocked on a syscall.fd 0/1/2 → /dev/pts/34 (deleted)— stdin/stdout/stderr point at a PTY slave that no longer exists (the xfce-terminal that owned it died).write(1, "<ANSI color + box-drawing bytes>", 2048) = -1 EIO, every entry returning EIO and minicom not checking the return value.The byte content was ANSI color sequences interspersed with
\333(octal 0333 = 0xDB =█, code-page-437 full block). It's a screen-redraw buffer — a menu or status display being re-emitted endlessly.So: when minicom's stdout dies underneath it, minicom busy-loops on the next
write()to that fd, gettingEIOevery time, ignoring the error, never breaking out. CPU goes to 100% on one core and the only way out is SIGKILL.Raw evidence
cat /proc/<pid>/status | head -8cat /proc/<pid>/wchanls -la /proc/<pid>/fdsudo strace -p <pid> -tt -e trace=read,write,poll,select,close(representative excerpt; the full capture is identical lines repeating thousands of times per second)Every line returned
-1 EIO. Inter-write gap is ~50 microseconds, which is the strace overhead — without strace attached, the loop would be even tighter.Speculative link to the BBS runaway
I think the same bug explains the BBS runaways too, with a different trigger. In the BBS case the terminal was still alive, so the writes would have succeeded — but minicom would still have been in a tight redraw loop driven by whatever internal state confusion happened during/after the ZModem session. The visible character pattern (
�0�0�0...decoded as alternating invalid-UTF-8 + ASCII0) is consistent with code-page-437 line-art being re-emitted by the same redraw loop, rendered through a UTF-8 terminal that can't decode it.I want to flag that link as speculative — the third repro has full strace evidence, but I haven't captured an strace of a BBS-triggered runaway, so the shared root cause is an inference.
Not a modemu2k bug
Worth being explicit: at the point the orphaned minicom was still spinning, modemu2k was already gone (
pgrep -l modemu2kreturned nothing). The runaway is purely a minicom-side render loop. Modemu2k is upstream of the failure, not the cause.Practical guidance
pkill minicomdoesn't work, usepkill -9 minicom(uncatchable SIGKILL).sudo strace -p <pid> -tt -e trace=read,write,poll,select,closeandcat /proc/<pid>/status/ls -la /proc/<pid>/fd.Upstream
I think this is worth filing against minicom upstream, which lives at https://salsa.debian.org/minicom-team/minicom (Arch's
minicompackage points there as its source URL). A report titled something like "minicom busy-loops on EIO writes when controlling terminal is destroyed" with the strace excerpt would be a clean submission. @andy5995 may decide whether to file it.If anyone reading this hits the same symptom against modemu2k, your data points would be valuable here.
All reactions