From: Eli Zaretskii <eliz@gnu.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: phst@google.com, p.stephani2@gmail.com, emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] master 74f54af: Use eassume (false) for branch that's never taken.
Date: Tue, 23 Apr 2019 20:19:49 +0300 [thread overview]
Message-ID: <835zr44p1m.fsf@gnu.org> (raw)
In-Reply-To: <e07766be-d56d-1c95-b848-be09e11ecacb@cs.ucla.edu> (message from Paul Eggert on Tue, 23 Apr 2019 09:56:15 -0700)
> Cc: p.stephani2@gmail.com, phst@google.com, emacs-devel@gnu.org
> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Tue, 23 Apr 2019 09:56:15 -0700
>
> On 4/22/19 11:19 PM, Eli Zaretskii wrote:
> > My mental model of using assertions in Emacs is slightly different.
> > In my model, we use eassert for things that "cannot happen", but can
> > be tolerated in some sense in a production build. "Tolerate" here
> > means that the result could be incorrect display or some strange error
> > message or a crash in some unrelated place.
>
> This is not a model I'm familiar with, and many (most?) executions of
> eassert don't behave that way. For example, when XCAR (via XCONS) uses
> eassert to check that its argument is tagged as a cons, any assertion
> failure means Emacs is in a seriously bad state. Quite possibly Emacs
> will crash immediately;
You just said in different words what I described.
> but even if Emacs lucks out and doesn't crash immediately it's not
> something that should be tolerated.
My model disagrees with "should" there. IMO, it's a judgment call
when to tolerate that and when not.
> For example, string_bytes has such a test, even though string_bytes
> won't crash immediately if the test is omitted.
I didn't say my model is followed consistently throughout our
sources. It's possible that string_bytes needs to be changed
(assuming that I will convince you to adopt my model ;-).
> In practice, I think the more accurate characterization is that we use
> eassert for runtime checks done in testing but not in production, and we
> use emacs_abort for runtime checks always done even in production.
That is also consistent with what I said.
> We're more likely to prefer emacs_abort to eassert if the runtime
> check is cheap or is rarely needed, or if the failure is more likely
> or has worse effects. Whether the failure would occur immediately
> after the check is not that relevant.
Like I said, it's a judgment call. What you describe are all valid
considerations, but they don't contradict my model.
> > And it doesn't help
> > that with current build machinery one needs to manually specify all
> > the compiler switches, instead of using some simple configure switch
> > that automatically does that for us. Using one more switch increases
> > that burden slightly.
>
> We could have --enable-checking default to -fsanitize=undefined on
> platforms that support it.
If it doesn't tremendously slow down Emacs, I think we should, yes.
prev parent reply other threads:[~2019-04-23 17:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-19 8:43 [Emacs-diffs] master 74f54af: Use eassume (false) for branch that's never taken Eli Zaretskii
2019-04-19 9:52 ` Philipp Stephani
2019-04-19 10:08 ` Eli Zaretskii
2019-04-19 19:04 ` Paul Eggert
2019-04-19 19:14 ` Philipp Stephani
2019-04-19 20:16 ` Eli Zaretskii
2019-04-19 20:14 ` Eli Zaretskii
2019-04-19 23:00 ` Paul Eggert
2019-04-20 6:25 ` Eli Zaretskii
2019-04-23 0:52 ` Paul Eggert
2019-04-23 6:19 ` Eli Zaretskii
2019-04-23 16:56 ` Paul Eggert
2019-04-23 17:19 ` Eli Zaretskii [this message]
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=835zr44p1m.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
--cc=p.stephani2@gmail.com \
--cc=phst@google.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).