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-10 (13:31)
From: ygrek <ygrekheretix@g...>
Subject: Re: [Caml-list] problem creating .cma library
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().

-- 
 ygrek
 http://ygrek.org.ua