all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* extract_data_from_object considered dangerous
@ 2019-09-22 13:39 Stefan Monnier
  2019-09-22 16:50 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2019-09-22 13:39 UTC (permalink / raw)
  To: emacs-devel

I was just looking at the calling convention of extract_data_from_object
and it seems intrinsically dangerous:

    It returns a char* into a Lisp_Object without associating it with
    any specific Lisp_Object

In some cases, the Lisp_Object into which the result points is freshly
allocated during the call, so once we return from the function, there is
no Lisp_Object reference to it anywhere any more to keep it from
being GC'd.


        Stefan




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: extract_data_from_object considered dangerous
  2019-09-22 13:39 extract_data_from_object considered dangerous Stefan Monnier
@ 2019-09-22 16:50 ` Eli Zaretskii
  2019-09-22 20:53   ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2019-09-22 16:50 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Sun, 22 Sep 2019 09:39:54 -0400
> 
>     It returns a char* into a Lisp_Object without associating it with
>     any specific Lisp_Object
> 
> In some cases, the Lisp_Object into which the result points is freshly
> allocated during the call, so once we return from the function, there is
> no Lisp_Object reference to it anywhere any more to keep it from
> being GC'd.

The original idea was to use the pointer right away, so that GC
couldn't happen.  If we want to lift this restriction, I think the
function should return a Lisp object, not a char *.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: extract_data_from_object considered dangerous
  2019-09-22 16:50 ` Eli Zaretskii
@ 2019-09-22 20:53   ` Stefan Monnier
  2019-09-23  2:28     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2019-09-22 20:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> The original idea was to use the pointer right away, so that GC
> couldn't happen.

Indeed, I think that it might be the case that currently this problem is
only hypothetical, but relying on "the GC probably can't happen now" is
too fragile for my taste.

> If we want to lift this restriction, I think the
> function should return a Lisp object, not a char *.

That's also my impression, but I was wondering is there was a good
reason why it wasn't done this way in the first place.


        Stefan




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: extract_data_from_object considered dangerous
  2019-09-22 20:53   ` Stefan Monnier
@ 2019-09-23  2:28     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2019-09-23  2:28 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: emacs-devel@gnu.org
> Date: Sun, 22 Sep 2019 16:53:05 -0400
> 
> > If we want to lift this restriction, I think the
> > function should return a Lisp object, not a char *.
> 
> That's also my impression, but I was wondering is there was a good
> reason why it wasn't done this way in the first place.

AFAIR, the function was created by consolidating many repeated in-line
code fragments.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-09-23  2:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-22 13:39 extract_data_from_object considered dangerous Stefan Monnier
2019-09-22 16:50 ` Eli Zaretskii
2019-09-22 20:53   ` Stefan Monnier
2019-09-23  2:28     ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.