caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] Bug in ocamlc or in ocamlrun.
  2006-04-18 23:16 Bug in ocamlc or in ocamlrun Marc Lasson
@ 2006-04-18 22:29 ` Jonathan Roewen
  2006-04-19  8:45 ` Keiko Nakata
  2006-04-19  9:33 ` Sebastian Egner
  2 siblings, 0 replies; 9+ messages in thread
From: Jonathan Roewen @ 2006-04-18 22:29 UTC (permalink / raw)
  To: Marc Lasson; +Cc: caml-list

Interesting.

I pasted into a toplevel (3.09.0), and it died with the message:

>> Fatal error: Primitive update_mod not found.
Fatal error: exception Misc.Fatal_error

That might be the cause...

Jonathan


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Bug in ocamlc or in ocamlrun.
@ 2006-04-18 23:16 Marc Lasson
  2006-04-18 22:29 ` [Caml-list] " Jonathan Roewen
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Marc Lasson @ 2006-04-18 23:16 UTC (permalink / raw)
  To: caml-list

Hello,

When i compile the following program with ocamlc i get a segmentation fault. 

Is it a bug in the ocaml system ? I did not succeed to isolate it.
                                 ----------------------
module LL (R : sig
 type t
 val add : t -> t -> t
end) =
 struct
   type t = R.t list
   let add = List.map2 (R.add)
 end

module rec M : sig
   type t = P of int | L of LS.t
   val add : t -> t -> t
   val to_string : t -> string
 end = struct
   type param = ()
   type t = P of int
               | L of LS.t
             let add a b = match a, b with
     P a', P b' -> P (a'+b')
   | L a', L b' -> L (LS.add a' b')
   | _ -> failwith "incompatible"

   let rec to_string = function
      P i -> string_of_int i
    | L l -> List.fold_left (fun r x -> r^" "^(to_string x)) "" l
 end
and LS : sig type t = M.t list val add : t -> t -> t end = LL(M)

open M
let p = L [P 1; P 2]
let q = add p p
let () =
 print_endline (to_string p);
 print_endline (to_string q)
                                 ----------------------

If i replace the function LL.add by

 let rec add a b = match a, b with
     [], [] -> []
   | x::a', y::b' -> (R.add x y)::(add a' b')
   | _ -> failwith "add"

the segmentation fault magically disappear.

Hope that helps,
-- 
Marc Lasson.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Bug in ocamlc or in ocamlrun.
  2006-04-18 23:16 Bug in ocamlc or in ocamlrun Marc Lasson
  2006-04-18 22:29 ` [Caml-list] " Jonathan Roewen
@ 2006-04-19  8:45 ` Keiko Nakata
  2006-04-19 19:38   ` Marc Lasson
  2006-04-19  9:33 ` Sebastian Egner
  2 siblings, 1 reply; 9+ messages in thread
From: Keiko Nakata @ 2006-04-19  8:45 UTC (permalink / raw)
  To: titmarc; +Cc: caml-list

From: Marc Lasson <titmarc@free.fr>
Subject: [Caml-list] Bug in ocamlc or in ocamlrun.
Date: Wed, 19 Apr 2006 01:16:27 +0200

> When i compile the following program with ocamlc i get a segmentation fault. 
> 
> Is it a bug in the ocaml system ? I did not succeed to isolate it.
>                                  ----------------------
> module LL (R : sig
>  type t
>  val add : t -> t -> t
> end) =
>  struct
>    type t = R.t list
>    let add = List.map2 (R.add)
>  end
> 
> module rec M : sig
>    type t = P of int | L of LS.t
>    val add : t -> t -> t
>    val to_string : t -> string
>  end = struct
>    type param = ()
>    type t = P of int
>                | L of LS.t
>              let add a b = match a, b with
>      P a', P b' -> P (a'+b')
>    | L a', L b' -> L (LS.add a' b')
>    | _ -> failwith "incompatible"
> 
>    let rec to_string = function
>       P i -> string_of_int i
>     | L l -> List.fold_left (fun r x -> r^" "^(to_string x)) "" l
>  end
> and LS : sig type t = M.t list val add : t -> t -> t end = LL(M)
> 
> open M
> let p = L [P 1; P 2]
> let q = add p p
> let () =
>  print_endline (to_string p);
>  print_endline (to_string q)


Strangely, OCaml version 3.08.0 can handle this code.
So, the developer team must know the reason.
Did you write a bug report ?

Keiko NAKATA



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Bug in ocamlc or in ocamlrun.
  2006-04-18 23:16 Bug in ocamlc or in ocamlrun Marc Lasson
  2006-04-18 22:29 ` [Caml-list] " Jonathan Roewen
  2006-04-19  8:45 ` Keiko Nakata
@ 2006-04-19  9:33 ` Sebastian Egner
  2006-04-19  9:44   ` Jonathan Roewen
  2 siblings, 1 reply; 9+ messages in thread
From: Sebastian Egner @ 2006-04-19  9:33 UTC (permalink / raw)
  To: Marc Lasson; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 512 bytes --]

> When i compile the following program with ocamlc i get a segmentation 
fault. 
> [...]
> If i replace the function LL.add by
> 
>  let rec add a b = match a, b with
>      [], [] -> []
>    | x::a', y::b' -> (R.add x y)::(add a' b')
>    | _ -> failwith "add"
> 
> the segmentation fault magically disappear.

It seems that it is sufficient to define

        let add a b = List.map2 R.add a b

instead of

        let add = List.map2 R.add

to make the segmentation fault disappear (Ocaml 3.09.1).

Sebastian.

[-- Attachment #2: Type: text/html, Size: 961 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Bug in ocamlc or in ocamlrun.
  2006-04-19  9:33 ` Sebastian Egner
@ 2006-04-19  9:44   ` Jonathan Roewen
  2006-04-19 10:55     ` Sebastian Egner
  0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Roewen @ 2006-04-19  9:44 UTC (permalink / raw)
  To: Sebastian Egner; +Cc: Marc Lasson, caml-list

> It seems that it is sufficient to define
>
>         let add a b = List.map2 R.add a b
>
> instead of
>
>         let add = List.map2 R.add
>
> to make the segmentation fault disappear (Ocaml 3.09.1).

That is besides the point =P The fact is that the code -does- segfault
while there is nothing syntactically (and probably semanticly) wrong
with the code.

Jonathan


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Bug in ocamlc or in ocamlrun.
  2006-04-19  9:44   ` Jonathan Roewen
@ 2006-04-19 10:55     ` Sebastian Egner
  2006-04-19 20:24       ` Alain Frisch
  0 siblings, 1 reply; 9+ messages in thread
From: Sebastian Egner @ 2006-04-19 10:55 UTC (permalink / raw)
  To: caml-list; +Cc: Jonathan Roewen

[-- Attachment #1: Type: text/plain, Size: 640 bytes --]

Besides the point or not, here is a much simpler version of
Marc's program which also segfaults (ocamlc 3.09.1), and 
probably due to the same reason:

---

module type Aut =
  sig 
    type t 
    val f : t -> t 
  end

module Map(A : Aut) =
  struct
    type t = A.t list
    let f = List.map A.f (* => Segmentation fault *)
(*  let f x = List.map A.f x *) (* => Stack overflow (correct) *)
  end

module rec M : (Aut with type t = int) =
  struct
    type t
    let f x = 
      match MapM.f [x] with 
      | [y] -> y 
      | _   -> assert false
  end
and MapM : (Aut with type t = M.t list) = 
  Map(M)

open M;;
M.f 0

---

Sebastian

[-- Attachment #2: Type: text/html, Size: 1791 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Bug in ocamlc or in ocamlrun.
  2006-04-19 19:38   ` Marc Lasson
@ 2006-04-19 18:57     ` Remi Vanicat
  0 siblings, 0 replies; 9+ messages in thread
From: Remi Vanicat @ 2006-04-19 18:57 UTC (permalink / raw)
  To: Marc Lasson; +Cc: Keiko Nakata, caml-list

2006/4/19, Marc Lasson <titmarc@free.fr>:
> Keiko Nakata wrote:
>
> >Strangely, OCaml version 3.08.0 can handle this code.
> >So, the developer team must know the reason.
> >Did you write a bug report ?
> >
> >
> According to <http://caml.inria.fr/pub/distrib/ocaml-3.09/notes/Changes>,
> there was a change about recursive modules. They may have add a bug.
>
> > Did you write a bug report ?
> >
> Hum. Should I ?

Yes, please do. The member of the ocaml teams don't read all message
here, but they read all bug report

> I am not expert at all, i have never written any bug report.

Just give the example telling what happen

> I don't know many things about ocaml sources.

You don't need to to send bug report. Bug report only state problems,
and the ocaml team will ask for further information if it's needed


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Bug in ocamlc or in ocamlrun.
  2006-04-19  8:45 ` Keiko Nakata
@ 2006-04-19 19:38   ` Marc Lasson
  2006-04-19 18:57     ` Remi Vanicat
  0 siblings, 1 reply; 9+ messages in thread
From: Marc Lasson @ 2006-04-19 19:38 UTC (permalink / raw)
  To: Keiko Nakata; +Cc: caml-list

Keiko Nakata wrote:

>Strangely, OCaml version 3.08.0 can handle this code.
>So, the developer team must know the reason.
>Did you write a bug report ?
>  
>
According to <http://caml.inria.fr/pub/distrib/ocaml-3.09/notes/Changes>,
there was a change about recursive modules. They may have add a bug.

> Did you write a bug report ?
>
Hum. Should I ?
I am not expert at all, i have never written any bug report.
I don't know many things about ocaml sources.

-- 
Marc Lasson.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Bug in ocamlc or in ocamlrun.
  2006-04-19 10:55     ` Sebastian Egner
@ 2006-04-19 20:24       ` Alain Frisch
  0 siblings, 0 replies; 9+ messages in thread
From: Alain Frisch @ 2006-04-19 20:24 UTC (permalink / raw)
  To: Sebastian Egner; +Cc: caml-list

Sebastian Egner wrote:
> Besides the point or not, here is a much simpler version of
> Marc's program which also segfaults (ocamlc 3.09.1), and
> probably due to the same reason:

And here's yet a simpler one:
module rec M : (sig val f : int list -> int list end) =
struct let f = List.map succ end
let _ = M.f []

I've submitted a bug report.

-- Alain


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-04-19 20:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-18 23:16 Bug in ocamlc or in ocamlrun Marc Lasson
2006-04-18 22:29 ` [Caml-list] " Jonathan Roewen
2006-04-19  8:45 ` Keiko Nakata
2006-04-19 19:38   ` Marc Lasson
2006-04-19 18:57     ` Remi Vanicat
2006-04-19  9:33 ` Sebastian Egner
2006-04-19  9:44   ` Jonathan Roewen
2006-04-19 10:55     ` Sebastian Egner
2006-04-19 20:24       ` Alain Frisch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).