From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 7DCFBBC75 for ; Wed, 2 Mar 2005 23:32:32 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j22MWWiJ003324 for ; Wed, 2 Mar 2005 23:32:32 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA30578 for ; Wed, 2 Mar 2005 23:32:31 +0100 (MET) Received: from bernache.ens-lyon.fr (bernache.ens-lyon.fr [140.77.167.10]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j22MWVwu012816 for ; Wed, 2 Mar 2005 23:32:31 +0100 Received: by bernache.ens-lyon.fr (Postfix, from userid 103) id 231497ABD46; Wed, 2 Mar 2005 23:32:31 +0100 (CET) Received: from [192.168.0.252] (79.221.97-84.rev.gaoland.net [84.97.221.79]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client did not present a certificate) by bernache.ens-lyon.fr (Postfix) with ESMTP id 449BC7ABD44 for ; Wed, 2 Mar 2005 23:32:05 +0100 (CET) Message-ID: <42263EE3.6020701@ens-lyon.org> Date: Wed, 02 Mar 2005 23:32:03 +0100 From: Samuel Mimram User-Agent: Debian Thunderbird 1.0 (X11/20050116) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Caml List Subject: interaction between *_blocking_section and value X-Enigmail-Version: 0.89.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 42263F00.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 42263EFF.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ens-lyon:01 threads:01 bindings:01 camlparam:01 camlprim:01 camlparam:01 val:01 camlreturn:01 val:01 scope:01 interaction:01 interaction:01 macros:01 data:02 data:02 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: Hello, I'd like to have some clarifications about the interaction between threads and the GC in C bindings. As far as I understand the CAMLparam and CAMLlocal macros prevent values from being garbage-collected i.e. 1. being completely removed from memory, 2. being *moved* during the whole scope of the C function (am I right?). I have received a mail concerning one of my programs which was telling me that this is not true when in blocking sections, and that values can be moved by the GC. Is it the case? Consider the following code: CAMLprim value caml_send(value data) { CAMLparam1(data); enter_blocking_section(); send(0, String_val(data), string_length(data)); leave_blocking_section(); CAMLreturn(Val_unit); } Is it safe or can the String_val(data) point to an invalid portion of memory because data have been move by the GC because of the enter_blocking_section()? Also, it would be nice if the *_blocking_section() could be explained in the documentation. Thanks. Regards, Samuel.