[Top][All Lists]

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

Re: GC and simple smobs??

From: Jean Abou Samra
Subject: Re: GC and simple smobs??
Date: Sat, 18 Jun 2022 00:01:24 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1

Le 17/06/2022 à 23:49, David Kastrup a écrit :
Jean Abou Samra <> writes:

By the way, I have a side question. Suppose I have determined
that I need to mark the local variable scm_obj with
scm_remember_upto_here in this code:

SCM scm_obj = get_it_from_somewhere ();

return something_that_needs_scm_obj_alive;

// Is this correct?
scm_remember_upto_here (scm_obj);

Might the compiler detect that return exits the function and
ignore the scm_remember_upto_here?
return; releases the stack frame.  "return
something_that_needs_scm_obj_alive;" is not a valid pattern unless the
returned value itself is an SCM that will cover scm_obj in its GC scope.

Well, I was thinking of something like this:

Pitch *p = unsmob<Pitch> (scm_pitch);
return *p;
scm_remember_upto_here (scm_pitch); // ??

where I thought GC could happen between 'unsmob<Pitch>' and
'return *p', making p a dangling pointer. If you are correct
about GC only being triggered upon (Guile) allocations, that
wouldn't be a concern.

reply via email to

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