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 MAA01070; Mon, 12 Jul 2004 12:55:14 +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 MAA00940 for ; Mon, 12 Jul 2004 12:55:13 +0200 (MET DST) Received: from mail.npc.de (fw.npc.de [62.225.140.214]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i6CAtBSH008553 for ; Mon, 12 Jul 2004 12:55:12 +0200 Received: from styx.ffm.npc.de (lion.npc.de [192.168.129.1]) by mail.npc.de (Postfix) with ESMTP id 9555F181B; Mon, 12 Jul 2004 12:55:10 +0200 (CEST) Received: from hera.ffm.npc.de (hera.ffm.npc.de [192.168.130.8]) by styx.ffm.npc.de (Postfix STYX NPC GmbH) with ESMTP id 8CA23C437; Mon, 12 Jul 2004 12:55:10 +0200 (CEST) Received: from ares.ffm.npc.de (ares.ffm.npc.de [192.168.130.32]) by hera.ffm.npc.de (Postfix HERA NPC GmbH) with ESMTP id 48198159C9; Mon, 12 Jul 2004 12:55:10 +0200 (CEST) Received: from ares.ffm.npc.de (ares.ffm.npc.de [192.168.130.32]) by ares.ffm.npc.de (Postfix ARES NPC GmbH) with ESMTP id 047AD1855; Mon, 12 Jul 2004 12:55:09 +0200 (CEST) Subject: Re: [Caml-list] Toplevel crashes when trying to call external functions From: Gerd Stolpmann To: John Prevost Cc: ayerkes@speakeasy.net, caml-list@inria.fr In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 12 Jul 2004 12:55:09 +0200 Message-Id: <1089629710.21716.12.camel@ares> Mime-Version: 1.0 X-Miltered: at concorde with ID 40F26E0F.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 crashes:01 gerd:01 stolpmann:01 2004:99 prevost:01 non-caml:01 curses:01 initscr:01 curses:01 non-caml:01 opaque:01 caml's:01 pointers:01 runtime:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Am Mon, 2004-07-12 um 05.39 schrieb John Prevost: > You shouldn't have to package up a non-caml managed pointer in any > sort of caml structure at all. Take a look at section 18.6 of the > manual, specifically the definitions of curses_initscr and > curses_wrefresh. Any pointer that's outside the caml heap (that is, > pretty much any pointer that you're getting from a non-caml function) > can simply be treated as opaque, and you can use Caml's type system to > make sure it's valid (as long as the C code always handles these > pointers correctly.) In principle, this is correct, but there are traps. For example, consider the case the memory block is freed by the C routine, and the same block is allocated by the caml runtime. In this case, the pointer, once outside the caml heap, is now inside, and the GC crashes. Because of this, I would not recommend this technique. Custom blocks (or int32 blocks) are risk-free in this regard. Gerd -- ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de ------------------------------------------------------------ ------------------- 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