unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Pip Cet <pipcet@gmail.com>
To: Matt Armstrong <matt@rfc20.org>
Cc: 46988@debbugs.gnu.org
Subject: bug#46988: 28.0.50; Documenting and verifying assumptions about C code not calling quit or GCing
Date: Wed, 10 Mar 2021 19:09:29 +0000	[thread overview]
Message-ID: <CAOqdjBeA9D4dTsc+crLPoz7b6EBEZ9dWbi5Thq0Zy861fkvRBg@mail.gmail.com> (raw)
In-Reply-To: <87a6ra7ti3.fsf@rfc20.org>

On Wed, Mar 10, 2021 at 6:28 PM Matt Armstrong <matt@rfc20.org> wrote:
> Pip Cet <pipcet@gmail.com> writes:
>
> Hey Pip, just minor comments from me.

Thanks (I'm responding to my email in a LIFO fashion after receiving a
new computer)!

> (I assume you already plan to put the use of the cleanup attribute
> behind conditional macros for portability)

Yes, absolutely.

> Why a linked list/stack implementation?  How about a global count var
> that is incremented, decremented, and asserted zero?

Emacs' specpdl implementation is independent of, and probably
predates, the widespread availability of C exceptions. In fact, as it
is written today, C exceptions will not work in Emacs C code (neither
will C++ exceptions), because Emacs uses setjmp / longjmp instead, and
unwinds the stack by itself. Since I was too lazy to fix it to use
compatible unwinding routines on supported platforms, I simply created
a linked list on the stack, unwinding it in unwind_to_catch.

> You wrote that this impl depends on the stack direction, but I can't
> figure out why.  If it is indeed the case, add a comment explaining
> this?

The unwind_to_catch code checks how far up the stack it has to go by
comparing the stack pointer to the address of a local variable. You're
absolutely right about the comment.

> As a macro name, I think something like ASSERT_NO_GC_IN_SCOPE would be
> clearer.

Thanks! You're quite right, I chose that as a placeholder, and
explicitly mentioning the scope is a really good idea.

> Signaling that this is a "magical" scope based construct is useful
> because this sort of thing is so unusual in C.  The first thing I looked
> for was an "END_SCOPE" macro and started scratching my head.
>
> I'd also use a clear that indicates a debug time check (ASSERT,
> CRASH_IF, etc.)
>
> "Don't allow" states an invariant but does not clearly indicate a
> consequence or other intent.  It could imply something as polite as "GC
> is disabled for this scope".
>
> For the C level stuff, maybe call it gc_forbidden_scope?

I like your proposed names!

> > + /* Do not wrap into do { } while (0). */
>
> Move the comment next to the #define.  Ideally, don't issue a command
> for the next programmer but instead explain why the code is the way is.

Yes, you're right. It's impolite at best. I'll try to avoid that in future.

Thanks again
Pip





  reply	other threads:[~2021-03-10 19:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-07 13:47 bug#46988: 28.0.50; Documenting and verifying assumptions about C code not calling quit or GCing Pip Cet
2021-03-07 14:06 ` Pip Cet
2021-03-08 19:42   ` Lars Ingebrigtsen
2021-03-08 19:57     ` Pip Cet
2021-03-09 14:05       ` Lars Ingebrigtsen
2021-03-10 18:28   ` Matt Armstrong
2021-03-10 19:09     ` Pip Cet [this message]
2021-03-11 23:17       ` Matt Armstrong
2022-06-20  1:41   ` Lars Ingebrigtsen
2022-06-20 11:47     ` Eli Zaretskii
2022-06-23 15:56       ` Pip Cet
2022-06-23 16:08         ` Eli Zaretskii
2022-06-23 16:20           ` Mattias Engdegård
2022-06-23 16:35             ` Eli Zaretskii

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=CAOqdjBeA9D4dTsc+crLPoz7b6EBEZ9dWbi5Thq0Zy861fkvRBg@mail.gmail.com \
    --to=pipcet@gmail.com \
    --cc=46988@debbugs.gnu.org \
    --cc=matt@rfc20.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).