[Top][All Lists]

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

Re: Conservative GC isn't safe

From: Ken Raeburn
Subject: Re: Conservative GC isn't safe
Date: Mon, 28 Nov 2016 04:50:56 -0500

On Nov 27, 2016, at 10:39, Eli Zaretskii <address@hidden> wrote:
>> From: Ken Raeburn <address@hidden>
>> Date: Sun, 27 Nov 2016 01:17:54 -0500
>> Cc: address@hidden
>>> 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.
>> I’d be surprised if that held reliably when the last use of a Lisp_Object in 
>> some function extracts an object pointer and then never references the 
>> Lisp_Object as such ever again.
>> Lisp_Object foo (Lisp_Object obj)
>> {
>>  …
>>  return mumble (XSYMBOL (obj));
>> }
>> It’s got no reason to specifically obfuscate the value, but it may also have 
>> no reason to keep a copy of the Lisp_Object value around when it’s no longer 
>> needed.  It’s not so much that the compiler has decided to start using an 
>> interior pointer on its own, but instead just doing what we told it to do.  
>> If “mumble” triggers GC, stack marking may well find only the pointer and 
>> not the original “obj” value in this function, especially if the compiler 
>> optimizes away the stack frame of “foo” completely.
> IOW, you envision the possibility that the object identified by 'obj'
> is not held in any stack-based memory cell in any of the 'foo's
> callers, and instead all of them hold that object only in registers?
> Is that a reasonable assumption?

Anything held in registers should get scanned by GC as well, once setjmp forces 
them into memory.
But if the caller never refers to the object again, it’s certainly possible 
that it wouldn’t keep around any copies of the Lisp_Object value, even in other 
registers, once it’s set up the arguments for the one function call that uses 
the object.  If the caller also created the object, there may not be any other 
references left.


reply via email to

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