English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
problem creating .cma library
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-01-11 (18:01)
From: Guillaume Yziquel <guillaume.yziquel@c...>
Subject: Re: [Caml-list] problem creating .cma library
ygrek a écrit :
> On Sat, 09 Jan 2010 20:36:07 +0100
> Guillaume Yziquel <guillaume.yziquel@citycable.ch> wrote:
>> So if I want to call R code that multithreads with OCaml, I should write 
>> something like
>>>   enter_blocking_section();
>>>   PROTECT(e = R_tryEval(Sexp_val(sexp_list), R_GlobalEnv, &error));
>>>   UNPROTECT(1);
>>>   leave_blocking_section();
>> Am I correct?
> I bet no. It is not safe to access block ocaml value
> inside blocking_section. In this particular case Sexp_val(v) is Field
> (v,0) whis in turn is v[0] or *v. So you read the pointer, then in
> another thread GC moves things around and old copy of the pointed
> value is overwritten, then you read the value through 
> the old pointer and get garbage.
> Put Sexp_val call before caml_enter_blocking_section().

OK. Thanks....

      Guillaume Yziquel