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 DAA03488; Sun, 11 Jul 2004 03:20:50 +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 DAA00933 for ; Sun, 11 Jul 2004 03:20:49 +0200 (MET DST) Received: from web53203.mail.yahoo.com (web53203.mail.yahoo.com [206.190.39.219]) by nez-perce.inria.fr (8.12.10/8.12.10) with SMTP id i6B1KmEV024206 for ; Sun, 11 Jul 2004 03:20:48 +0200 Message-ID: <20040711012047.86808.qmail@web53203.mail.yahoo.com> Received: from [155.97.235.24] by web53203.mail.yahoo.com via HTTP; Sat, 10 Jul 2004 18:20:47 PDT Date: Sat, 10 Jul 2004 18:20:47 -0700 (PDT) From: Andy Yang Subject: [Caml-list] Toplevel crashes when trying to call external functions To: caml-list@inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Miltered: at nez-perce with ID 40F095F0.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; crashes:01 camlparam:01 solver:01 val:01 alloc:01 val:01 solver:01 camlreturn:01 mng:99 camlparam:01 mng:99 char:01 camlreturn:01 abstr:01 abstr:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 ); } void zchaff_ReadCnf(value mng, value filename) { CAMLparam2(mng, filename); void* solver = (void*)Int32_val(mng); char * fn = String_val(filename); read_cnf(solver, fn); CAMLreturn0; } When I call these functions in a .ml file. It is okay. .However, when I tried to call these functions interactively, segmentation fault happens. The interactive way is as follows: # let solver = zchaff_InitManager () ;; solver = 0x8092328 val solver : zchaff_solver = # Gc.full_major();; - : unit = () # solver ;; - : zchaff_solver = # let _ = zchaff_ReadCnf solver "testcase/4.cnf";; solver = 0x400 file = testcase/4.cnf Segmentation fault It seems that the variable "solver" is not registered in Gc's root tree. So solver's value changes after Gc.full_major(). Where are wrong in my codes? Tracing with gdb, the stack is as follows when segmentation fault happens. #0 0x0807120f in obj_tag () #1 0x08074c8f in interprete () #2 0x08075dbe in caml_main () #3 0x08067a9c in main () Thanks a lot! Andy __________________________________ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. 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