Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000156OCamlOCaml generalpublic2000-07-06 18:402000-07-08 21:04
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000156: Bug is List.sort
DescriptionHello,
  The following program crashes:

let _ =
  let a = Array.init 100 (fun _ -> Random.float 1.0) in
  let l = Array.to_list a in
  let l = List.sort compare l in
  ()

Fatal error: uncaught exception Invalid_argument("Array.get")


It must be a bug in List.sort, because with Array.sort this works fine.
I may add a request, as has been discussed in the list recently, to add
an optional feature that shows where the exception was thrown. This
(new) bug has occured in a 100,000 lines of code system (Ensemble). It is
difficult to find a bug in such a large system without language level
help.

   Thanks,
    Ohad.

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0000415)
administrator (administrator)
2000-07-08 21:04

>From: orodeh@cs.huji.ac.il

> let _ =
> let a = Array.init 100 (fun _ -> Random.float 1.0) in
> let l = Array.to_list a in
> let l = List.sort compare l in
> ()
>
> Fatal error: uncaught exception Invalid_argument("Array.get")
>
>
> It must be a bug in List.sort, because with Array.sort this works fine.

This is a bug in Obj.truncate, which makes List.sort fail on all lists
of floats (except the empty list), but only on 32-bit machines. Many
thanks for finding and reporting the bug. I'm including a patch at the
end of this mail.

-- Damien

Index: byterun/obj.c
===================================================================
RCS file: /net/pauillac/caml/repository/csl/byterun/obj.c,v
retrieving revision 1.13
diff -c -r1.13 obj.c
*** obj.c 2000/04/03 08:34:22 1.13
--- obj.c 2000/07/08 18:33:33
***************
*** 102,107 ****
--- 102,109 ----
    mlsize_t wosize = Wosize_hd (hd);
    mlsize_t i;
  
+ if (tag == Double_array_tag) new_wosize *= Double_wosize; /* PR#156 */
+
    if (new_wosize <= 0 || new_wosize > wosize)
      invalid_argument ("Obj.truncate");
    if (new_wosize == wosize) return Val_unit;

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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker