On 08/16/2011 12:53 PM, Dmitry Bely wrote:
> On Tue, Aug 16, 2011 at 1:46 PM,  <ri...@happyleptic.org> wrote:
>> -[ Tue, Aug 16, 2011 at 11:43:24AM +0300, Török Edwin ]----
>>> 'list' should be reachable via caml_local_roots, so if it really gets an 
>>> invalid value
>>> it sounds like a bug to me.
>>
>> list may not be garbage collected (since it is indeed registered as the
>> root), but it may be moved arround (ie promoted to major heap).
>> The address of list would be fixed in the local variable (the root) but
>> not the transiant copy on the stack.
>> Maybe that's the actual problem ?
> 
> Exactly. List is moved but its stack copy (wrp_ml_cons 2nd parameter)
> is not updated and holds an old address.

Ah yes.
So a best practice would be to always use a temporary variable
registered with CAMLlocal* when you call a function that can potentially invoke 
the GC?
(in your example to store the result of caml_copy_string).

Best regards,
--Edwin

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to