unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Pip Cet <pipcet@gmail.com>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: emacs-diffs@gnu.org, emacs-devel@gnu.org
Subject: Re: master 9227864: Further fix for aborts due to GC losing pseudovectors
Date: Tue, 26 May 2020 08:02:27 +0000	[thread overview]
Message-ID: <CAOqdjBfPTaAUKHov0PHXWboVr4VxOfpWdMPqvYj6+R16GbF1xA@mail.gmail.com> (raw)
In-Reply-To: <26b54430-b654-3e13-8e3c-2f4482af60e1@cs.ucla.edu>

On Tue, May 26, 2020 at 7:40 AM Paul Eggert <eggert@cs.ucla.edu> wrote:
> On 5/26/20 12:25 AM, Pip Cet wrote:
> > roundup_size still uses LISP_ALIGNMENT here, so I don't see how that's
> > true.
>
> Oh, you're right. No harm so far since LISP_ALIGNMENT is 8 on current platforms.
> But this area could use some thinking if we want more efficiency on platforms
> where it's 16 (so far, I've been worried only about avoiding crashes on such
> machines).

Absolutely. I like the idea of an allocate_aligned_pseudovector API,
though it should be stubbed out (using eassert_reachable, or
_Static_assert) for now.

> >>> I think a simple eassert (GCALIGNMENT % alignof (type) == 0) in an
> >>> (inlined, obviously) version of allocate_pseudovector should suffice
> >>> to catch this hypothetical problem.
> >>
> >> I assume you meant 'verify' rather than 'eassert'? That'd catch the bug at
> >> compile time.
> >
> > I don't see how that would be possible using inline functions?
>
> We should use macros, as they'll catch this at compile-time.

Okay.

> (I don't know how to do an eassert_reachable.)

Something like

extern int __unreachable_function (int);

#define eassert(cond)                    \
  ({                            \
    if (__builtin_constant_p ((cond) && __unreachable_function((cond) != 0))) \
      {                            \
    *(int *)0 = 0;                    \
    __unreachable_function (0);            \
      }                            \
    eassert_1 (cond);                    \
  })

This provides a compile-time warning (easily upgraded to an error with
the right -Werror switch), a link-time error, and a run-time
assertion. It's not pretty, but it gets the job done.

FWIW, with this (invalid) version of eassert, the following correct,
but weird, code generates a link-time error:

    case Lisp_Int:
      eassert ("should not be dumping int: is self-representing" && 0);
      abort ();

But, at -O2/-O3, on x86_64-pc-linux-gnu, no other places in the build
appear to be using eassert (0).

> We're already using macros for ALLOCATE_PSEUDOVECTOR and the like, so this should not be a big deal.

I'm finding it hard to do so, but I'm not used to working with
_Static_assert and will try again.



  reply	other threads:[~2020-05-26  8:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200526060645.22243.34109@vcs0.savannah.gnu.org>
     [not found] ` <20200526060646.662E120A2C@vcs0.savannah.gnu.org>
2020-05-26  6:40   ` master 9227864: Further fix for aborts due to GC losing pseudovectors Pip Cet
2020-05-26  7:09     ` Paul Eggert
2020-05-26  7:25       ` Pip Cet
2020-05-26  7:40         ` Paul Eggert
2020-05-26  8:02           ` Pip Cet [this message]
2020-05-26 14:51           ` Stefan Monnier
2020-05-26 17:25             ` Pip Cet
2020-05-26 17:46               ` Stefan Monnier

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=CAOqdjBfPTaAUKHov0PHXWboVr4VxOfpWdMPqvYj6+R16GbF1xA@mail.gmail.com \
    --to=pipcet@gmail.com \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-diffs@gnu.org \
    /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).