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 QAA21362; Fri, 16 Jul 2004 16:10:51 +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 QAA20448 for ; Fri, 16 Jul 2004 16:10:50 +0200 (MET DST) Received: from kaiserslautern1.lms-gmbh.de ([212.43.68.201]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i6GEAnEV025333 for ; Fri, 16 Jul 2004 16:10:49 +0200 Received: by kaiserslautern1.lms-gmbh.de with Internet Mail Service (5.5.2653.19) id <3YLJG6A5>; Fri, 16 Jul 2004 16:10:49 +0200 Message-ID: From: "Bauer, Christoph" To: caml-list Subject: [Caml-list] segfault in caml_copy_string Date: Fri, 16 Jul 2004 16:10:47 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C46B3E.B1463810" X-Miltered: at nez-perce with ID 40F7E1E9.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; bauer:01 bauer:01 segfault:01 camlprim:01 camlparam:01 const:01 char:01 camlreturn:01 camlreturn:01 segfault:01 camlprim:01 camlparam:01 const:01 char:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C46B3E.B1463810 Content-Type: text/plain Hi, here is a simple C-function: CAMLprim value getparam(value request, value key) { CAMLparam2(request, key); const char * result; CAMLreturn(key); /* 1 */ CAMLreturn(caml_copy_string("test")); /* 2 */ } Version 1 returns the key and everything works (except that key is not what I need.) Version 2 calls caml_copy_string and this fails. Has anybody a idea why? OCaml Version is 3.08.0. Thanks for help, Christoph Bauer ------_=_NextPart_001_01C46B3E.B1463810 Content-Type: text/html segfault in caml_copy_string

Hi,

here is a simple C-function:

CAMLprim value getparam(value request, value key)
{
  CAMLparam2(request, key);
  const char * result;
  CAMLreturn(key);  /* 1 */
  CAMLreturn(caml_copy_string("test")); /* 2 */
 }

Version 1 returns the key and everything works (except that
key is not what I need.)

Version 2 calls caml_copy_string and this fails. Has anybody a idea why?

OCaml Version is 3.08.0.

Thanks for help,
Christoph Bauer

------_=_NextPart_001_01C46B3E.B1463810-- ------------------- 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 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 QAA21900; Fri, 16 Jul 2004 16:22:55 +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 QAA21799 for ; Fri, 16 Jul 2004 16:22:54 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i6GEMrSH011781 for ; Fri, 16 Jul 2004 16:22:53 +0200 Received: from bourg.inria.fr (bourg.inria.fr [128.93.11.100]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA21729 for ; Fri, 16 Jul 2004 16:22:53 +0200 (MET DST) Received: from basile by bourg.inria.fr with local (Exim 4.34) id 1BlTbT-0004SN-7D for caml-list@inria.fr; Fri, 16 Jul 2004 16:22:23 +0200 Date: Fri, 16 Jul 2004 16:22:23 +0200 To: caml-list@inria.fr Subject: Re: [Caml-list] segfault in caml_copy_string Message-ID: <20040716142223.GA17108@bourg.inria.fr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6+20040523i From: "Basile Starynkevitch [local]" X-Miltered: at concorde with ID 40F7E4BD.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 segfault:01 basile:01 basile:01 2004:99 bauer:01 camlprim:01 camlparam:01 const:01 char:01 camlreturn:01 camlreturn:01 allocates:01 camlprim:01 camlparam:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, Jul 16, 2004 at 04:10:47PM +0200, Bauer, Christoph wrote: > Hi, > > here is a simple C-function: > > CAMLprim value getparam(value request, value key) > { > CAMLparam2(request, key); > const char * result; > CAMLreturn(key); /* 1 */ > CAMLreturn(caml_copy_string("test")); /* 2 */ > } > > Version 1 returns the key and everything works (except that > key is not what I need.) > > Version 2 calls caml_copy_string and this fails. Has anybody a idea why? caml_copy_string actually allocates a *garbage-collected* string, so you need to tell about its result to the GC. Try instead CAMLprim value getparam(value request, value key){ CAMLparam2(request, key); CAMLlocal1(result); result = caml_copy_string("test"); CAML_return(result); } (to understand why, read any material on precise moving garbage collectors) -- Basile STARYNKEVITCH -- basile dot starynkevitch at inria dot fr Project cristal.inria.fr - phone +33 1 3963 5197 - mobile 6 8501 2359 http://cristal.inria.fr/~starynke --- all opinions are only mine ------------------- 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