* [Caml-list] Compiler killer code?
@ 2002-06-08 14:32 Alessandro Baretta
2002-06-08 14:34 ` William Lee Irwin III
0 siblings, 1 reply; 11+ messages in thread
From: Alessandro Baretta @ 2002-06-08 14:32 UTC (permalink / raw)
To: Ocaml
Is the type inference algorithm guaranteed to termintate? I
ask because I have accidentally attempted to evaluate a
(meaningless) function which almost hanged my Athlon.
The killer code is the following:
type t = t -> t
let f (x:t) :t = f f
If I type this into the toplevel, it starts to allocate
memory by the tens of megabytes, until I have to kill it to
prevent a system crash. I let it reach approximately 128MB
before killing it. (BTW, that was with ocaml 3.04+13
2002-06-05.)
Is the language really supposed to accept such garbage as
that which I wrote?
Alex
-------------------
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] Compiler killer code?
2002-06-08 14:32 [Caml-list] Compiler killer code? Alessandro Baretta
@ 2002-06-08 14:34 ` William Lee Irwin III
2002-06-08 18:30 ` William Lovas
2002-06-09 13:29 ` Alessandro Baretta
0 siblings, 2 replies; 11+ messages in thread
From: William Lee Irwin III @ 2002-06-08 14:34 UTC (permalink / raw)
To: Alessandro Baretta; +Cc: Ocaml
On Sat, Jun 08, 2002 at 04:32:13PM +0200, Alessandro Baretta wrote:
> Is the type inference algorithm guaranteed to termintate? I
> ask because I have accidentally attempted to evaluate a
> (meaningless) function which almost hanged my Athlon.
> The killer code is the following:
> type t = t -> t
> let f (x:t) :t = f f
> If I type this into the toplevel, it starts to allocate
> memory by the tens of megabytes, until I have to kill it to
> prevent a system crash. I let it reach approximately 128MB
> before killing it. (BTW, that was with ocaml 3.04+13
> 2002-06-05.)
> Is the language really supposed to accept such garbage as
> that which I wrote?
I get this instead:
# type t = t -> t;;
The type abbreviation t is cyclic
Cheers,
Bill
-------------------
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] Compiler killer code?
2002-06-08 14:34 ` William Lee Irwin III
@ 2002-06-08 18:30 ` William Lovas
2002-06-09 13:29 ` Alessandro Baretta
1 sibling, 0 replies; 11+ messages in thread
From: William Lovas @ 2002-06-08 18:30 UTC (permalink / raw)
To: William Lee Irwin III; +Cc: Alessandro Baretta, Ocaml
On Sat, Jun 08, 2002 at 07:34:02AM -0700, William Lee Irwin III wrote:
> > Is the type inference algorithm guaranteed to termintate? I
> > ask because I have accidentally attempted to evaluate a
> > (meaningless) function which almost hanged my Athlon.
> > The killer code is the following:
> > type t = t -> t
> > let f (x:t) :t = f f
> > If I type this into the toplevel, it starts to allocate
> > memory by the tens of megabytes, until I have to kill it to
> > prevent a system crash. I let it reach approximately 128MB
> > before killing it. (BTW, that was with ocaml 3.04+13
> > 2002-06-05.)
> > Is the language really supposed to accept such garbage as
> > that which I wrote?
I wonder if it really would have crashed your system, or if O'Caml would
have simply died with an `out of memory' error.
> On Sat, Jun 08, 2002 at 04:32:13PM +0200, Alessandro Baretta wrote:
>
> I get this instead:
>
> # type t = t -> t;;
> The type abbreviation t is cyclic
If you use recursive types (`ocaml -rectypes'), it typechecks fine:
# type t = t -> t;;
type t = t -> t
# let rec f (x : t) : t = f f;;
val f : t = <fun>
In fact, you don't even need to define the type abbreviation:
# let rec f x = f f;;
val f : 'a -> 'b as 'a = <fun>
This is O'Caml 3.04 -- if it fails to typecheck in the CVS version, then
i'd say either the semantics of recursive types have changed or a bug has
been introduced.
cheers,
William
-------------------
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] Compiler killer code?
2002-06-08 14:34 ` William Lee Irwin III
2002-06-08 18:30 ` William Lovas
@ 2002-06-09 13:29 ` Alessandro Baretta
2002-06-09 13:41 ` Xavier Leroy
2002-06-10 2:42 ` Jacques Garrigue
1 sibling, 2 replies; 11+ messages in thread
From: Alessandro Baretta @ 2002-06-09 13:29 UTC (permalink / raw)
To: Ocaml
William Lee Irwin III wrote:
> I get this instead:
>
> # type t = t -> t;;
> The type abbreviation t is cyclic
>
> Cheers,
> Bill
Here's what I do.
Objective Caml version 3.04+13 (2002-06-05)
# type t = t -> t ;;
type t = t -> t
# let rec f (x:t) = f f ;;
Interrupted.
Question for the developers: are "-rectypes" automatically
enabled in the CVS version I am using?
Alex
-------------------
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] Compiler killer code?
2002-06-09 13:29 ` Alessandro Baretta
@ 2002-06-09 13:41 ` Xavier Leroy
2002-06-09 18:08 ` Blair Zajac
2002-06-10 2:42 ` Jacques Garrigue
1 sibling, 1 reply; 11+ messages in thread
From: Xavier Leroy @ 2002-06-09 13:41 UTC (permalink / raw)
To: Alessandro Baretta; +Cc: Ocaml
> Objective Caml version 3.04+13 (2002-06-05)
>
> # type t = t -> t ;;
> type t = t -> t
> # let rec f (x:t) = f f ;;
> Interrupted.
This looks like a bug in the development version. Without the
-rectypes flag, the declaration of t should be rejected, like it is in
OCaml 3.04. Interestingly, the development version handles your
example just fine when -rectypes is set.
A note to users of the development version: we appreciate your
testing, but please keep the latest official release around to check
weird behaviors, and when you observe a discrepancy like the above,
report it to caml-bugs@inria.fr.
- Xavier Leroy
-------------------
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] Compiler killer code?
2002-06-09 13:41 ` Xavier Leroy
@ 2002-06-09 18:08 ` Blair Zajac
2002-06-10 10:57 ` [Caml-list] " Michal Moskal
2002-06-10 15:25 ` [Caml-list] " Xavier Leroy
0 siblings, 2 replies; 11+ messages in thread
From: Blair Zajac @ 2002-06-09 18:08 UTC (permalink / raw)
To: Xavier Leroy; +Cc: Alessandro Baretta, Ocaml
Xavier Leroy wrote:
>
> > Objective Caml version 3.04+13 (2002-06-05)
> >
> > # type t = t -> t ;;
> > type t = t -> t
> > # let rec f (x:t) = f f ;;
> > Interrupted.
>
> This looks like a bug in the development version. Without the
> -rectypes flag, the declaration of t should be rejected, like it is in
> OCaml 3.04. Interestingly, the development version handles your
> example just fine when -rectypes is set.
>
> A note to users of the development version: we appreciate your
> testing, but please keep the latest official release around to check
> weird behaviors, and when you observe a discrepancy like the above,
> report it to caml-bugs@inria.fr.
I think this points to something that should be considered for
future Ocaml development, that being a comprehensive test suite
to check the language. This would also help test porting of the
language to new OSes.
All of the major compilers I can think of, Perl, Python, GCC, etc,
have a test suite and I think from a company's point of view looking
to use the language, a test suite written in Caml would give additional
credibility and a sense of professionalism that would only help
adoption rates.
A good model for the test suite would be Perl's test suite which checks
every aspect of the language and its modules and is written in Perl
itself.
Is there any interest in this?
Best,
Blair
--
Blair Zajac <blair@orcaware.com>
Web and OS performance plots - http://www.orcaware.com/orca/
-------------------
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Caml-list] Re: Compiler killer code?
2002-06-09 18:08 ` Blair Zajac
@ 2002-06-10 10:57 ` Michal Moskal
2002-06-12 8:37 ` Xavier Leroy
2002-06-10 15:25 ` [Caml-list] " Xavier Leroy
1 sibling, 1 reply; 11+ messages in thread
From: Michal Moskal @ 2002-06-10 10:57 UTC (permalink / raw)
To: caml-list
On Sun, Jun 09, 2002 at 11:08:19AM -0700, Blair Zajac wrote:
> A good model for the test suite would be Perl's test suite which checks
> every aspect of the language and its modules and is written in Perl
> itself.
>
> Is there any interest in this?
And what about 2 stage bootstrap, with comprasion of generated object
files? Or maybe it's not so needed as it is in gcc? Anyway it would be
easier to make Makefiles comparse object files then write the testsuite,
but I don't know how usefull might it be.
--
: Michal Moskal ::::: malekith/at/pld-linux.org : GCS {C,UL}++++$ a? !tv
: PLD Linux ::::::: Wroclaw University, CS Dept : {E-,w}-- {b++,e}>+++ h
-------------------
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] Compiler killer code?
2002-06-09 18:08 ` Blair Zajac
2002-06-10 10:57 ` [Caml-list] " Michal Moskal
@ 2002-06-10 15:25 ` Xavier Leroy
1 sibling, 0 replies; 11+ messages in thread
From: Xavier Leroy @ 2002-06-10 15:25 UTC (permalink / raw)
To: Blair Zajac; +Cc: Alessandro Baretta, Ocaml
> I think this points to something that should be considered for
> future Ocaml development, that being a comprehensive test suite
> to check the language.
No one can object to this -- just like no one can object to "regular
exercice at the gym is good for you"; it's just that few have the
fortitute to actually do it. Developing a good test suite takes about
as much effort as writing the software being tested.
For OCaml, we have some test suites for a few specific libraries and
run-time facilities, but that's about it. Compilers and type-checkers
are even harder to test than run-time libraries.
So, if anyone wants to tackle this challenge, that would be very
useful indeed, but be aware that it's a huge task.
- Xavier Leroy
-------------------
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] Compiler killer code?
2002-06-09 13:29 ` Alessandro Baretta
2002-06-09 13:41 ` Xavier Leroy
@ 2002-06-10 2:42 ` Jacques Garrigue
2002-06-10 7:47 ` Alessandro Baretta
1 sibling, 1 reply; 11+ messages in thread
From: Jacques Garrigue @ 2002-06-10 2:42 UTC (permalink / raw)
To: alex; +Cc: caml-list
From: Alessandro Baretta <alex@baretta.com>
> Objective Caml version 3.04+13 (2002-06-05)
>
> # type t = t -> t ;;
> type t = t -> t
> # let rec f (x:t) = f f ;;
> Interrupted.
That's a bug: the compiler is never supposed to loop. At least in the
core language.
As already pointed out, the bug is on the first line: you shouldn't be
able to define such a type without -rectypes.
> Question for the developers: are "-rectypes" automatically
> enabled in the CVS version I am using?
No. This is just a bug. Now fixed.
As Xavier remarked, questions regarding the CVS version should go to
caml-bugs@pauillac.inria.fr as most people on this list do not use it.
An extra advantage is that then we can do bug tracking, and your bug
id would appear in the CVS log.
Thank you for this bug report. This helped correcting on overlooked
bug.
Jacques Garrigue
-------------------
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] Compiler killer code?
2002-06-10 2:42 ` Jacques Garrigue
@ 2002-06-10 7:47 ` Alessandro Baretta
0 siblings, 0 replies; 11+ messages in thread
From: Alessandro Baretta @ 2002-06-10 7:47 UTC (permalink / raw)
To: Ocaml
Jacques Garrigue wrote:
>>Question for the developers: are "-rectypes" automatically
>>enabled in the CVS version I am using?
>
>
> No. This is just a bug. Now fixed.
> As Xavier remarked, questions regarding the CVS version should go to
> caml-bugs@pauillac.inria.fr as most people on this list do not use it.
> An extra advantage is that then we can do bug tracking, and your bug
> id would appear in the CVS log.
>
> Thank you for this bug report. This helped correcting on overlooked
> bug.
>
> Jacques Garrigue
>
You are more than welcome. Thank you both, instead, for the
continual improvements to O'Caml. I enjoy programming in
O'Caml more than in any other language.
I'll keep in mind your comment about the caml-bugs reporting
system. If I notice any strange behavior in the CVS version
I'll ask you guys through that address.
Alex
-------------------
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
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2002-06-12 8:38 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-08 14:32 [Caml-list] Compiler killer code? Alessandro Baretta
2002-06-08 14:34 ` William Lee Irwin III
2002-06-08 18:30 ` William Lovas
2002-06-09 13:29 ` Alessandro Baretta
2002-06-09 13:41 ` Xavier Leroy
2002-06-09 18:08 ` Blair Zajac
2002-06-10 10:57 ` [Caml-list] " Michal Moskal
2002-06-12 8:37 ` Xavier Leroy
2002-06-10 15:25 ` [Caml-list] " Xavier Leroy
2002-06-10 2:42 ` Jacques Garrigue
2002-06-10 7:47 ` Alessandro Baretta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox