Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000058OCamlOCaml generalpublic2000-03-15 22:352000-03-17 14:29
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000058: crashing ocamlopt (Alpha)
DescriptionHello,

when I tried out my additions to the standard library with your latest
CVS-version (OCaml 2.99+10, date 15.03.2000), I found a bug which is
obviously in the native code generator.

Platform: Digital Unix 4.0e / Alpha

I have attached a simplified version of an offending module at the end of
this report. Other programs may also cause this, as I noticed.

The output of the compiler varies when one changes offending files:
sometimes it core dumps, sometimes it raises an exception, etc. With this
specific file, the following output occurs on my machine:

  spilled-i/116 spilled-x/117 spilled-env/118 spilled-res/119
  @`ï``b`````/119
  >> Fatal error: Liveness.fundecl
  Uncaught exception: Misc.Fatal_error

I know that the CVS-version is alpha-software, but I wanted to test
compilation of the system with my new stdlib-functions (which work well, as
I have verified).

Best regards and good bug hunting,
Markus Mottl

--
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl [^]


file: pres_impl.ml
compile with: ocamlopt.opt -c pres_impl.ml
---------------------------------------------------------------------------
module type Implementation = sig
  type 'a t
  val name : string
  val length : 'a t -> int
  val make : int -> 'a -> 'a t
  val unsafe_get : 'a t -> int -> 'a
  val unsafe_set : 'a t -> int -> 'a -> unit
end

module Make (S : Strat.T) (Impl : Implementation) = struct
  module Strategy = S

  type strategy = Strategy.t

  type 'a t = {mutable ar : 'a Impl.t;
               mutable vlix : int;
               mutable strategy : strategy}

  let name = Impl.name

  let invalid_arg str = invalid_arg (name ^ "." ^ str)

  let length ra = succ ra.vlix

  let real_length ra = Impl.length ra.ar
  let real_lix ra = pred (real_length ra)

  let unsafe_get ra = Impl.unsafe_get ra.ar
  let unsafe_set ra = Impl.unsafe_set ra.ar

  let dummy_loc = 0
  let no_obj () = Obj.magic dummy_loc

  let creator n = let nothing = no_obj () in Impl.make n nothing

  let screate_fresh strategy n =
    let res = {ar = no_obj (); vlix = pred n; strategy = strategy} in
    Strategy.grow strategy (fun rlen -> res.ar <- creator rlen) n; res

  let create_fresh n = screate_fresh Strategy.default n

  let create_from ra =
    {ar = creator (length ra); vlix = ra.vlix; strategy = ra.strategy}

  let sempty strategy =
    let res = {ar = no_obj (); vlix = -1; strategy = strategy} in
    Strategy.grow strategy (fun rlen -> res.ar <- creator rlen) 0; res

  let screate strategy n x =
    let res = screate_fresh strategy n in
    for i = 0 to pred n do unsafe_set res i x done; res

  let sinit strategy n f =
    let res = screate_fresh strategy n in
    for i = 0 to pred n do unsafe_set res i (f i) done; res

  let resizer some_lix ra len =
    let ar = creator len in
    for i = 0 to some_lix do Impl.unsafe_set ar i (unsafe_get ra i) done;
    ra.ar <- ar

  let enforce_strategy ra =
    let real_len = real_length ra and len = length ra in
    Strategy.shrink ra.strategy (resizer ra.vlix ra) real_len len
end

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0000325)
administrator (administrator)
2000-03-16 11:35

Hi,

> module Make (S : Strat.T) (Impl : Implementation) = struct

I'm trying to reproduce your bug, but I'm afraid we'll need the file
strat.ml for that...

-- Damien
(0000326)
administrator (administrator)
2000-03-16 17:40

Hello,

> > module Make (S : Strat.T) (Impl : Implementation) = struct
>
> I'm trying to reproduce your bug, but I'm afraid we'll need the file
> strat.ml for that...

I am awefully sorry! Trying to reduce the size of the file as much as
possible, I completely overlooked this dependency... (see missing file
below).

There is a funny aspect about the problem:

Compiling "strat.ml" and "pres_impl.ml" as follows:

  ocamlopt -c strat.ml pres_impl.ml

works without problems!

But:

  ocamlopt -c strat.ml
  ocamlopt -c pres_impl.ml

This messes up the terminal, but using "copy&paste" with the mouse shows
you this:

  spilled-i/116 spilled-x/117 spilled-env/118 spilled-res/119
  ðí@`ï``b`````/119
  >> Fatal error: Liveness.fundecl
  Uncaught exception: Misc.Fatal_error

In the terminal window, only the first line (spilled...) is readable,
everything else looks rather strange. But ok, such things can happen if a
program goes wild... ;-)

I received many other strange messages while reducing the file more and
more so don't trust the output above as indication to the problem...

Best regards,
Markus Mottl

File: strat.ml
---------------------------------------------------------------------------
module type T = sig
  type t

  val default : t

  val grow : t -> (int -> unit) -> int -> unit
  val shrink : t -> (int -> unit) -> int -> int -> unit
end
---------------------------------------------------------------------------

--
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl [^]

(0000327)
administrator (administrator)
2000-03-16 20:06

Having read your notes in the bugtracking list:

Yes, sorry: I also forgot to mention that I normally move "ocamlopt.opt" to
"ocamlopt" when I install things - a probably very bad habit (especially
when one forgets to mention this in bug reports). It, of course, makes a
difference whether a byte code program crashes or a native code one...

Regards,
Markus Mottl

--
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl [^]

(0000328)
administrator (administrator)
2000-03-17 14:28

Thanks for the missing file. Damien and I were able to find the bug.
It's a case of a memory root (in the stack) not being mentioned to the GC.
The bug is a consequence of a simplification of the C-- intermediate language
that I did one week ago, but turns out to be incorrect. The sources now
in the CVS repository compiles your example correctly.

Thanks for the well-delineated bug report,

- Xavier Leroy
(0000329)
administrator (administrator)
2000-03-17 14:29

Crashes "ocamlopt.opt" but not "ocamlopt" on my machine. -- Damien
Bug introduced 2000/03/12, fixed 2000/03/17 by Xavier.

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker