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 NAA01470; Mon, 12 Jul 2004 13:04:04 +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 NAA01333 for ; Mon, 12 Jul 2004 13:04:03 +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 i6CB42SH009619 for ; Mon, 12 Jul 2004 13:04:02 +0200 Received: from styx.ffm.npc.de (lion.npc.de [192.168.129.1]) by mail.npc.de (Postfix) with ESMTP id 808F7181B; Mon, 12 Jul 2004 13:04:01 +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 A2173C437; Mon, 12 Jul 2004 13:04:01 +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 5690B159C9; Mon, 12 Jul 2004 13:04:01 +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 26FEC1855; Mon, 12 Jul 2004 13:04:01 +0200 (CEST) Subject: Re: [Caml-list] Toplevel crashes when trying to call external functions From: Gerd Stolpmann To: Andy Yang Cc: art yerkes , caml-list@inria.fr In-Reply-To: <20040711185802.8039.qmail@web53203.mail.yahoo.com> References: <20040711185802.8039.qmail@web53203.mail.yahoo.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 12 Jul 2004 13:04:00 +0200 Message-Id: <1089630241.21716.21.camel@ares> Mime-Version: 1.0 X-Miltered: at concorde with ID 40F27022.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 unlucky:01 2004:99 pointers:01 camlparam:01 camllocal:01 val:01 solver:01 val:01 solver:01 endl:01 camlreturn:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Of course, the problem can be anywhere, we don't see the code you are calling. The stubs look reasonable, and it is very likely that your problem is an unlucky interference with the C++ part. Am Son, 2004-07-11 um 20.58 schrieb Andy Yang: > Hi, > > Since at this point, I am not concerning much about > codes' portability, so I just assume the program run > on x86 machines, on which 32 bits pointers are > allowed.I modified code as follows: > > value zchaff_InitManager(void) > { > CAMLparam0(); > CAMLlocal1(val); > void* solver = SAT_InitManager(); > val = copy_int32((int)solver); > cout<<"solver = "< CAMLreturn ( val ); > } > > void zchaff_ReadCnf(value mng, value filename) > { > CAMLparam2(mng, filename); > SAT_Manager solver = (void*)Int32_val(mng); > cout<<"solver = "< assert(solver != NULL); > char * fn = String_val(filename); For example, this line can be problematic if fn is modified by read_cnf. > cout<<"file = "< read_cnf(solver, fn); > CAMLreturn0; > } > > > Thus I should follows ocaml's Tag rules. However, the > problem still exists. Tracing with gdb, I noticed that > the toplevel still crashes in function obj_tag. > However, I cannot find the obj_tag 's sourcecode in > Ocaml's source. There is only a mapping table in > ocaml_dir/byterun/prims.c, in which obj_tag is one of > the primitives. > > Thanks a lot! > > Andy > > > > > > Hi, all > > > > > > I am relatively new to Ocaml. Sorry about the spam > > if > > > this is a trivial problem. I am trying to give > > call > > > some external functions. > > > > > > Some codes are as follows: > > > > > > value zchaff_InitManager(void) > > > { > > > CAMLparam0(); > > > void * solver = SAT_InitManager(); > > > value val = alloc(1, Custom_tag); > > > Int32_val(val) = (int) solver; > > > CAMLreturn ( val ); > > > } > > > > > > } > > > > > > > These may not solve this specific problem but I > > think they are good > > advice: > > > > First: > > 17.9.2. Custom blocks must be allocated via the > > alloc_custom function. > > (And remember that the custom block size argument is > > in bytes). > > > > Second: > > Passing 1 as the block size to alloc allocates a > > block with one word > > as a tail (at offset 0), but Data_custom_val > > accesses a value in the > > tail at offset 1. This is probably the error you're > > looking for. > > > > Third: > > I don't understand why you're going through > > Int32_val and Val_int32 > > to get and set your pointer. You probably want to > > write a new macro > > that will access the custom area as a pointer-sized > > chunk on every > > architecture. Assuming pointers to be 32-bits > > really is a bad idea. > > -- > > Hey, Adam Smith, keep your invisible hands to > > yourself! > > > > > > > > > __________________________________ > Do you Yahoo!? > Yahoo! Mail is new and improved - Check it out! > http://promotions.yahoo.com/new_mail > > ------------------- > 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 > > -- ------------------------------------------------------------ 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