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 LAA17538; Mon, 5 Aug 2002 11:51:26 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 LAA17481 for ; Mon, 5 Aug 2002 11:51:25 +0200 (MET DST) Received: from mel-rto3.wanadoo.fr (smtp-out-3.wanadoo.fr [193.252.19.233]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g759pPP03445; Mon, 5 Aug 2002 11:51:25 +0200 (MET DST) Received: from mel-rta9.wanadoo.fr (193.252.19.69) by mel-rto3.wanadoo.fr (6.5.007) id 3D49FC7D0011ED27; Mon, 5 Aug 2002 11:51:25 +0200 Received: from warp (80.13.116.114) by mel-rta9.wanadoo.fr (6.5.007) id 3D49FFB700114954; Mon, 5 Aug 2002 11:51:25 +0200 Message-ID: <003901c23c65$9fe95e30$0700a8c0@warp> From: "Nicolas Cannasse" To: "Xavier Leroy" Cc: "kyra" , "OCaml" References: <000901c237fe$04a92510$0700a8c0@warp> <001901c239b4$be8ccbf0$551aa8c0@kyra> <001101c23a0d$2f184220$0700a8c0@warp> <000d01c23ae3$9dd62700$551aa8c0@kyra> <003b01c23c54$32324570$0700a8c0@warp> <20020805113255.C7554@pauillac.inria.fr> Subject: Re: [Caml-list] OCam'OLE pre-release Date: Mon, 5 Aug 2002 11:51:08 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > The job of the GC is to release unreferenced objects. > > But I don't see how this can cause a bug : it seems that your crash is due > > to a call of a COM method on a object AFTER it has been released... if it > > has been Release, then it is no longer referenced by Ocaml... so , how can u > > ever call a method on it ??? > > Because the COM object can still be referenced from C. You probably > forgot to do an AddRef somewhere, e.g. when extracting a COM object > reference from its Caml wrapper. > > Reference count management sure is tricky... True. If you're using OCamole to manipulate COM objects and then passing them back to C, your C code need to call AddRef on the retreived COM object since OCamole GC'ed process does not respect the COM spec (caller is responsible from Release, callee call AddRef ) Simply use the following function : IUnknown *get_com_object( value v ) { IUnknown *o = IUnknown_val(v); o->AddRef(); return o; } Nicolas Cannasse ------------------- 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