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 IAA24342; Mon, 12 Jul 2004 08:58:41 +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 IAA23960 for ; Mon, 12 Jul 2004 08:58:40 +0200 (MET DST) Received: from mailfe05.swip.net (mailfe05.swip.net [212.247.154.129]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i6C6wdEV006051 for ; Mon, 12 Jul 2004 08:58:39 +0200 X-T2-Posting-ID: ImwvLa5aE1cGKKFOhEcPPAuNPk19+u9IoltGuamDNnU= Received: from [213.103.216.71] (HELO tele2.fr) by mailfe05.swip.net (CommuniGate Pro SMTP 4.2b6) with ESMTP id 97702381 for caml-list@inria.fr; Mon, 12 Jul 2004 08:58:38 +0200 Message-ID: <40F235E3.5070600@tele2.fr> Date: Mon, 12 Jul 2004 08:55:31 +0200 From: Anne Pacalet User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.6) Gecko/20040113 X-Accept-Language: fr, en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] Toplevel crashes when trying to call external functions References: <20040711012047.86808.qmail@web53203.mail.yahoo.com> In-Reply-To: <20040711012047.86808.qmail@web53203.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Miltered: at nez-perce with ID 40F2369F.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; tele:99 caml-list:01 crashes:01 extern:01 camlparam:01 val:01 camlreturn:01 extern:01 camlparam:01 camllocal:01 val:01 camlreturn:01 refs':01 ecrit:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Andy Yang a écrit : > I am relatively new to Ocaml. I am VERY new to Ocaml... > When I call these functions in a .ml file. It is okay. > .However, when I tried to call these functions > interactively, segmentation fault happens. and I have to same problem with even the simplest functions. For instance : extern "C" void Caml_load_project(value v_0){ CAMLparam1(v_0); String x_0 = String_val (v_0); C_load_project (x_0); CAMLreturn0; } extern "C" value Caml_show_refs(value v_0, value v_1){ CAMLparam2(v_0, v_1); CAMLlocal1 (v_res); int x_0 = Int_val (v_0); int x_1 = Int_val (v_1); std::list res = C_show_refs (x_0, x_1); v_res = Val_listInt (res); CAMLreturn (v_res); } And I noticed that if I add "flush" or "print" calls, it works. So, I did : external c_load_project : string -> unit = "Caml_load_project" external c_show_refs : int -> int -> int list = "Caml_show_refs" let load_project a_0 = c_load_project a_0 ; flush_all() ;; let show_refs a_0 a_1 = let r = c_show_refs a_0 a_1 in flush_all() ; r ;; and the functions 'load_project' and 'show_refs' work fine even interactively. I don't know why (I would be happy to know)... but maybe this workaround can help ! Bye, Anne. ------------------- 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