From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA11036; Sun, 1 Jun 2003 13:10:45 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA11116 for ; Sun, 1 Jun 2003 13:10:44 +0200 (MET DST) Received: from relay.pair.com (relay.pair.com [209.68.1.20]) by concorde.inria.fr (8.11.1/8.11.1) with SMTP id h51BAhH01308 for ; Sun, 1 Jun 2003 13:10:43 +0200 (MET DST) Received: (qmail 32884 invoked from network); 1 Jun 2003 11:10:42 -0000 Received: from arda.pair.com (HELO checkerdell.d6.com) (209.68.1.133) by relay.pair.com with SMTP; 1 Jun 2003 11:10:42 -0000 X-pair-Authenticated: 209.68.1.133 Message-Id: <4.3.2.7.2.20030601040609.01cbab00@localhost> X-Sender: checker@localhost X-Mailer: QUALCOMM Windows Eudora Version 4.3.2 Date: Sun, 01 Jun 2003 04:10:36 -0700 To: Maas-Maarten Zeeman From: Chris Hecker Subject: Re: [Caml-list] Question about register_global_root Cc: "Mary F. Fernandez" , caml-list@inria.fr, Jerome Simeon In-Reply-To: <3ED9DA78.4040601@wanadoo.nl> References: <3ED511E5.8060401@research.att.com> <4.3.2.7.2.20030601002350.01cf4310@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Spam: no; 0.00; hecker:01 checker:01 caml-list:01 val:01 interfacing:01 alloc:01 malloc:01 sizeof:01 camllocal:01 chris:01 caml:01 handler:01 unit:03 explicitly:03 variable:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >The manual explicitly tells that register_global_root should be called >before any valid value is stored in it for the first time, like Val_unit. >See Rule 4 of Interfacing C with Objective Caml in the manual. Yes, but you don't store immediately, you call the alloc_tuple: > handlers = (value *) malloc(sizeof(value)); > register_global_root(handlers); > *handlers = alloc_tuple(NUM_HANDLERS); If alloc_tuple has to collect, then the gc will scan *handlers but it is uninitialized data. If you called alloc_tuple above the register and stored it in a CAMLlocal variable, then just stuffed *handler immediately with that value after register I could see it working, but I don't see how the current code isn't a possible error. Maybe I'm misunderstanding how the GC works or something? Chris ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners