Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000024OCamlOCaml generalpublic2000-01-14 22:292000-02-07 15:03
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000024: thread-safety and I/O
DescriptionFull_Name: Gerd Stolpmann
Version: 2.04 -with-pthread
OS: Linux-2.2.13 with glibc-6.1
Submission from: master.proxy.ision.net (195.180.208.40)


The following piece of code "q.ml", compiled with
ocamlopt -o q -thread unix.cmxa threads.cmxa q.ml -cclib -lunix -cclib
-lthreadsnat -cclib -pthread
does not work if "n" is less than 1024.

"q.data" is a file with contents "abcd\n".

If it works correctly, the program must not produce any output.

let n = 1023 in
for i = 1 to 50 do (* 50 threads doing I/O *)
  let id =
    Thread.create
      (fun () ->
     for j = 1 to 100 do (* read the file 100 times *)
       let ch = open_in "q.data" in
       let u =
         let s = String.create n in
         ignore(input ch s 0 5);
         String.sub s 0 5
       in
       close_in ch;
       if u <> "abcd\n" then
         let v =
           Printf.sprintf "i=%d j=%d s=%s\n" i j u in
         prerr_endline v;
       done;
      )
      ()
  in
  l := id :: !l
done;

List.iter
  (fun id ->
     Thread.join id)
  !l
;;

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0000296)
administrator (administrator)
2000-02-07 15:03

Fixed in 3.00 (see PR#25)

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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker