[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspac
From: |
G. Branden Robinson |
Subject: |
[bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0' |
Date: |
Sat, 4 Sep 2021 06:51:58 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 |
Update of bug #61089 (project groff):
Status: Need Info => In Progress
_______________________________________________________
Follow-up Comment #13:
This experimental patch was instructive.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 4af8741e1..1b6a15755 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -2053,14 +2053,15 @@ static node *node_list_reverse(node *n)
static void distribute_space(node *n, int nspaces, hunits desired_space,
int force_reverse = 0)
{
+ hunits em = curenv->get_size();
+ double Ems = (double)desired_space.to_units() / nspaces
+ / (em.is_zero() ? hresolution : em.to_units());
+ debug("spreading %1m per space among %2 spaces", Ems, nspaces);
static int reverse = 0;
if (force_reverse || reverse)
n = node_list_reverse(n);
if (!force_reverse && nspaces > 0 && spread_limit >= 0
&& desired_space.to_units() > 0) {
- hunits em = curenv->get_size();
- double Ems = (double)desired_space.to_units() / nspaces
- / (em.is_zero() ? hresolution : em.to_units());
if (Ems > spread_limit)
output_warning(WARN_BREAK, "spreading %1m per space", Ems);
}
Input (pretty much John's reduced reproducer):
$ cat EXPERIMENTS/61089.roff
.de _
. na
. nh
. ll 0
. di A
.tm line length in diversion is \\n(.l
\&\\$1
. di
. br
..
._ " XYZ"
.tm line length is \n(.l
.A
Output:
line length in diversion is 0
troff: backtrace: 'EXPERIMENTS/61089.roff':7: macro '_'
troff: backtrace: file 'EXPERIMENTS/61089.roff':11
troff: EXPERIMENTS/61089.roff:11: debug: spreading -nanm per space among 0
spaces
troff: backtrace: 'EXPERIMENTS/61089.roff':7: macro '_'
troff: backtrace: file 'EXPERIMENTS/61089.roff':11
troff: EXPERIMENTS/61089.roff:11: warning [p 0, 0.0i, div 'A', 0.0i]: line has
non-positive width 0m
line length is 0
troff: warning [p 1, 0.0i]: can't break line
troff: debug: spreading 0m per space among 1 spaces
troff: ../src/roff/troff/env.cpp:2074: distribute_space(): assertion failed:
'desired_space.is_zero() && nspaces == 0'
/home/branden/src/GIT/groff/build/groff: error: troff: Aborted (core dumped)
Yeaaaaah. Check that out. NaNs (division by zero) and an attempt to spread
0m of space.
I think resolving this mess will involve three steps.
(1) Make distribute_space() more irritable about its inputs. If either
`nspaces` or `desired_space` is zero, return early. I might instrument this
check with a diagnostic, too, but maybe not because...
(2) In the short run I think we should do as Heirloom Doctools troff does and
clamp the line length to the horizontal resolution. This will require checks
on the implementation of the `ll` request and the code that reads the DESC
file in the first place. I'm reasonably familiar with these areas of the
codebase.
(3) Bring John's proposed zero-line-length semantics to the groff mailing
list. I have no particular objection to it but since that list is effectively
the entire troff community's sounding board, I think it's prudent to notify
and seek the feedback of other implementors and experts. If it survives
scrutiny there, implement it.
Whether (3) survives or not, I think either (1) or (2) should make it
unnecessary to add checks at the call sites of `distribute_space()`. (And if
I'm wrong, there is only a handful of such places.)
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?61089>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0', (continued)
- [bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0', G. Branden Robinson, 2021/09/01
- [bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0', Dave, 2021/09/02
- [bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0', Dave, 2021/09/02
- [bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0', G. Branden Robinson, 2021/09/02
- [bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0', G. Branden Robinson, 2021/09/02
- [bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0', G. Branden Robinson, 2021/09/02
- [bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0', John Gardner, 2021/09/02
- [bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0', Dave, 2021/09/02
- [bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0', G. Branden Robinson, 2021/09/03
- [bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0', John Gardner, 2021/09/03
- [bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0',
G. Branden Robinson <=
- [bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0', G. Branden Robinson, 2021/09/04
- [bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0', G. Branden Robinson, 2021/09/04
- [bug #61089] [troff] assertion failed: 'desired_space.is_zero() && nspaces == 0', G. Branden Robinson, 2021/09/04