[Top][All Lists]

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

Re: Conservative GC isn't safe

From: Stefan Monnier
Subject: Re: Conservative GC isn't safe
Date: Sat, 26 Nov 2016 10:03:39 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

>> 1) mark_maybe_pointer looks only for exact matches on object start. It's
>> perfectly legal for the compiler to keep an interior object pointer and
>> discard the pointer to the object start.
> Yes, just as it's perfectly legal for the compiler to subtract 42 from every
> pointer before putting it in a register or storing it into memory. In
> practice, though, compilers don't do this around calls to the garbage
> collector. (True, this assumption should be documented better.)

Indeed.  Hans Boehm's done a fair bit of research in this issue,
including discussing the underlying assumptions and arguing that
compilers should (and usually do) guarantee those assumptions.

>> 2) INTERVAL is GCed, but it's not represented in the memory tree: struct
>> interval isn't a real lisp object and it's allocated as
>> MEM_TYPE_NON_LISP. Even a direct pointer to the start of an interval won't
>> protect it from GC. Shouldn't we treat intervals like conses?
> Does the code ever create an interval that is accessible only via locals
> when a GC occurs? If not, Emacs should be OK. (This should also be
> documented better.)

Indeed, this is a fairly delicate assumption that we don't check.
It's fairly rare to manipulate "struct interval" directly, so I think
the assumption is probably acceptable, but we should maybe document it
more prominently.


reply via email to

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