ocaml / ocaml

The core OCaml system: compilers, runtime system, base libraries
https://ocaml.org
Other
5.22k stars 1.06k forks source link

Thread version of input_line #2410

Closed vicuna closed 24 years ago

vicuna commented 24 years ago

Original bug ID: 73 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Michael McDougall Version: 2.01, 2.02, 2.04 OS: Linux (2.01, 2.04) & Solaris 2.02 Submission from: halifax.cis.upenn.edu (158.130.66.10)

The problem:

The version of input_line which gets linked when you use the threads library will not return the contents of a 1 line file. It returns an EOF exception. The non-Threads version works fine.

How to reproduce:

  1. create a file 'testfile' that contains 1 line of text (ie. no '\n' characters). Example: (==== signifies start/end of a file)

    A one line file!

  2. Create an ml file called bugtest.ml:

==================================================== let file = open_in ("testfile") in let str = input_line file in print_string (str ^ "\n")

  1. Make 2 executables, one linked with the normal pervasives called "bugtest", the other with the thread-safe pervasives called "bugtestthreads".

%ocamlc -c bugtest.ml %ocamlc -custom unix.cma -cclib -lunix \ -o bugtest bugtest.cmo
%ocamlc -thread -custom unix.cma -cclib -lunix threads.cma -cclib -lthreads\ -o bugtestthreads bugtest.cmo

  1. Run the two executables. They should give the same output but the thread-safe version doesn't read the file.

%./bugtest jdshlkjshdlkjhsdljaslkjhsk %./bugtestthreads Fatal error: uncaught exception End_of_file

vicuna commented 24 years ago

Comment author: administrator

The version of input_line which gets linked when you use the threads library will not return the contents of a 1 line file. It returns an EOF exception. The non-Threads version works fine.

You're right. I just fixed this. Thanks for the bug report.

vicuna commented 24 years ago

Comment author: administrator

Fixed on 2000-04-03 by Xavier