URL: <https://savannah.gnu.org/bugs/?68980>
Summary: ms: footnote loops forever in nroff mode when FM is
a half-line multiple
Group: GNU roff
Submitter: jgm
Submitted: Sun 29 Nov 2026 10:39:55 PM UTC
Category: Macro package ms
Severity: 3 - Normal
Item Group: Crash/Unresponsive
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Unlocked
Planned Release: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Sun 29 Nov 2026 10:39:55 PM UTC By: John MacFarlane <jgm>
Summary
-------
With the ms macros in nroff mode, a document containing a footnote
makes troff loop forever, producing an endless series of pages, if the
bottom margin register FM is a whole number of lines plus half a line.
groff version: GNU groff 1.24.2 (macOS, arm64)
Reproduction
------------
$ cat fn.ms
.nr FM 1.25i
.LP
para\**
.FS
note
.FE
$ groff -ms -Tutf8 fn.ms
troff never terminates; the output consists of the text "para[1]"
followed by blank pages with increasing page numbers (1, 2, 3, ...).
The footnote text itself is never output.
The same happens with -Tascii, -Tlatin1, and `nroff -ms`.
It does not happen:
- without the footnote;
- in troff mode (e.g. -Tpdf or -Tps);
- with FM set to 1i, 1.1i, 1.3i, 1.5i, 7v, or 8v.
It also happens with FM 1.75i. On terminal devices a line is 40
basic units, so the failing values (1.25i = 300u = 7.5 lines,
1.75i = 420u = 10.5 lines) are exactly a whole number of lines plus
half a line. Values that are a whole number of lines, or not
a half-line multiple (1.1i = 6.6 lines, 1.3i = 7.8 lines), work.
Setting the top margin HM to 1.25i does not cause the problem.
Possible cause
--------------
I have not traced this through s.tmac in detail. The page-bottom
trap is planted at -\n[FM]u and the footer trap at -\n[FM]u/2u-1v;
fn@bottom-hook computes fn@bottom-pos from \n[.p]-\n[FM] and plants
fn*catch-overflow there. My guess is that when these positions fall
half a line off the vertical grid used in nroff mode, the footnote is
always judged not to fit, so it is diverted to fn@overflow-div and
carried to the next page, where the same thing happens again.
Workaround
----------
Round FM to a whole number of lines in nroff mode:
.nr FM 1.25i
.if n .nr FM \n[FM]/1v*1v
Context
-------
This was found via pandoc, whose default ms template sets
`.nr FM 1.25i`, so every pandoc-generated ms document with a footnote
hung when rendered to a terminal. Pandoc's template now uses the
workaround above.
Credit to Claude Opus 5.5 for identifying the bug and creating this report.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?68980>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
