emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master d582356: * src/fns.c (Frandom): Handle bignum `limit`s


From: Pip Cet
Subject: Re: master d582356: * src/fns.c (Frandom): Handle bignum `limit`s
Date: Sat, 6 Mar 2021 09:44:18 +0000

On Sat, Mar 6, 2021 at 8:45 AM Eli Zaretskii <eliz@gnu.org> wrote:
> > From: Pip Cet <pipcet@gmail.com>
> > Date: Sat, 6 Mar 2021 07:42:20 +0000
> > Cc: emacs-devel@gnu.org
> >
> > * src/buffer.c (Fgenerate_new_buffer_name): Call intern ("random").
>
> Previously, Fgenerate_new_buffer_name couldn't cause GC, but with this
> change it can, because the modified code calls funcall.  For the same
> reason, it could now QUIT, where it previously couldn't.

Thanks! You're quite right.

> So this
> change would need to be accompanied by auditing the C callers of
> Fgenerate_new_buffer_name, to make sure they don't use any code that
> doesn't expect any of these 2 events to happen (such as 'char *'
> pointers lying around, which might become invalid after GC).

I thought this code in code_conversion_save was safe:

      Lisp_Object name
        = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil);
      workbuf = Fget_buffer_create (name, Qt);

but I had misread the second argument to Fget_buffer_create: it's
inhibit-hooks, not run-hooks.

So I'm not sure whether code_conversion_save is allowed to call Lisp.
It would really help to document the "doesn't call Lisp" and "doesn't
quit" restrictions somewhere (but I'm not volunteering...)

As an alternative, we could simply use get_random() % 1000000 and
accept that the first 737418-ish buffer names are microscopically more
likely to be used on 32-bit narrow-int systems.

Pip



reply via email to

[Prev in Thread] Current Thread [Next in Thread]