tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: Baptiste Daroussin <bapt@freebsd.org>
Cc: tech@mandoc.bsd.lv
Subject: Re: Crash core dump when parsing krb5_openlog.3
Date: Fri, 13 Oct 2023 12:57:37 +0200	[thread overview]
Message-ID: <ZSkioWMVQRz7ocTV@asta-kit.de> (raw)
In-Reply-To: <opwdx67bgiaxlzbyjypiyl55wi4tpqt7oa56oioxqqqt37d6qj@ii3dtg2kbibb>

Hi Bapt,


Baptiste Daroussin wrote on Fri, Oct 13, 2023 at 09:06:56AM +0200:

> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=266882
> I haven't had time yet to debug, do you actually need more information?

No, the information in that report is perfect.
That's a very useful report, i replied to it here:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=266882#c2

Pasting the reply here, too:

Actually, with mandoc-current, i get a different assertion, but in
the same function, and judging from what i know about the code,
i hold a strong suspicion that the root cause is still the same,
i.e. that the same invariant is still being violated in the code:

$ mandoc krb5_openlog.3 assertion "rval != ESCAPE_EXPAND" failed:
file "/usr/src/usr.bin/mandoc/roff_escape.c", line 46, function
"mandoc_escape" Abort trap (core dumped)

This is a very important bug report because this particular bug has
already been reported a few weeks ago, but the reporter was unable
to provide a reproducer.  I tried to construct a reproducer from
code inspection but unfortunately failed.  So having the reproducer
is very valuable.

Right now, we are in the middle of an OpenBSD release, so it will
take up to a week before i will find the time of looking into this.

Apparently, the bug is that some particular roff(7) escape sequence is
likely regarded as output-device-dependent by the roff(7) pre-parser
and hence not substituted but instead left for the formatters to
handle, similar to the \*(.T predefined string, but the formatters
regards that particular escape sequence as one that should have been
replaced by the pre-parser, hence dying because they cannot handle it.

Having a quick look at your reproducing input file, i suspect that
the following input confuses mandoc:

.\" ouch!
.ds xx \\*(fP\fR(\fP\\*(lI*\\*(fP

Notably, you already marked that line with "ouch" in the manual
page source code, presumably acknowledging that doing such low-level
gymnastics in a manual page is asking for trouble.  To not handle such
madness gracefully is still a bug in mandoc though, i do not deny that.

I suspect that using the extremely special escape sequence "\\"
inside .ds is confusing mandoc - that sequence is mostly intended
for being used inside .de.  The pre-parser still sees the "\\" and
consequently sees no user-defined string replacement escape sequences.
But when the "xx" string is later used, the "\\*" likely gets resolved
to "\*", i.e. to a string replacement request, but at the point, the
pre-parser has already been run so the string does not get replaced
and makes it through to the formatters, and those cannot handle it.
Or something like that, i will have to investigate in detail.

No wonder i was unable to construct a reproducer from scratch, given
how crazy the reproducer actually looks...

Yours,
  Ingo
--
 To unsubscribe send an email to tech+unsubscribe@mandoc.bsd.lv


  reply	other threads:[~2023-10-13 10:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13  7:06 Baptiste Daroussin
2023-10-13 10:57 ` Ingo Schwarze [this message]
2023-10-21 17:54   ` Ingo Schwarze

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZSkioWMVQRz7ocTV@asta-kit.de \
    --to=schwarze@usta.de \
    --cc=bapt@freebsd.org \
    --cc=tech@mandoc.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).