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 QAA22733; Fri, 16 Jul 2004 16:39:09 +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 QAA22422 for ; Fri, 16 Jul 2004 16:39:08 +0200 (MET DST) Received: from kaiserslautern1.lms-gmbh.de ([212.43.68.201]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i6GEd7SH014111 for ; Fri, 16 Jul 2004 16:39:07 +0200 Received: by kaiserslautern1.lms-gmbh.de with Internet Mail Service (5.5.2653.19) id <3YLJG6CD>; Fri, 16 Jul 2004 16:39:07 +0200 Message-ID: From: "Bauer, Christoph" To: caml-list@inria.fr Subject: AW: [Caml-list] segfault in caml_copy_string Date: Fri, 16 Jul 2004 16:39:06 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C46B42.A5A0F820" X-Miltered: at concorde with ID 40F7E88B.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 caml-list:01 segfault:01 allocates:01 camlprim:01 camlparam:01 camllocal:01 stdlib:01 camlprim:01 getenv:01 char:01 getenv:01 val:01 caml-list: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_01C46B42.A5A0F820 Content-Type: text/plain > > 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) Thanks for the fast response. But ocaml/stdlib/sys.c contains this function: CAMLprim value caml_sys_getenv(value var) { char * res; res = getenv(String_val(var)); if (res == 0) caml_raise_not_found(); return caml_copy_string(res); } I found out that it is a links problem because of mixing a static library and a DLL. best regards, Christoph Bauer ------_=_NextPart_001_01C46B42.A5A0F820 Content-Type: text/html AW: [Caml-list] segfault in caml_copy_string

>
> 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)

Thanks for the fast response.
But ocaml/stdlib/sys.c contains this function:

CAMLprim value caml_sys_getenv(value var)
{
  char * res;

  res = getenv(String_val(var));
  if (res == 0) caml_raise_not_found();
  return caml_copy_string(res);
}

I found out that it is a links problem because of mixing a
static library and a DLL.

best regards,
Christoph Bauer

------_=_NextPart_001_01C46B42.A5A0F820-- ------------------- 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