* Segfault with close_out in ocaml 3.09.2
@ 2007-07-01 18:41 Jørgen Hermanrud Fjeld
2007-07-02 13:25 ` [Caml-list] " Martin Jambon
0 siblings, 1 reply; 2+ messages in thread
From: Jørgen Hermanrud Fjeld @ 2007-07-01 18:41 UTC (permalink / raw)
To: caml-list
[-- Attachment #1.1: Type: text/plain, Size: 1124 bytes --]
Hi!
I can provoke a segfault with close_out, and suspect a bug somewhere in
ocaml 3.09.2 or the Pervasives module of ocaml 3.09.2, as shipping with
Ubuntu feisty.
To reproduce, save the attached files, use ocaml 3.09.2 and run
####
ocamlopt unix.cmxa -o nosegfault nosegfault.ml
ocamlopt unix.cmxa -o segfault segfault.ml
./nosegfault ; ./segfault
####
The difference between segfault.ml and nosegfault.ml is the allocation
of a large string
####
let _ = String.create (Sys.max_string_length) in
####
The bug appears for the second call to close_out.
When I use Unix.close, there is no problem.
The original code where the testcase is derived form ran fine when
compiled with ocaml 3.08.
When I use ocaml 3.10.0 the problem is gone.
If someone can help discover why the segfault appears that would be
nice.
Since the bug disappears in ocaml 3.10, the bug is probably fixed,
which one can check when the cause of the segfault is discovered.
--
Sincerely | Homepage:
Jørgen | http://www.hex.no/jhf
| Public GPG key:
| http://www.hex.no/jhf/key.txt
[-- Attachment #1.2: segfault.ml --]
[-- Type: text/plain, Size: 695 bytes --]
let run closer command =
let (from_command,to_command) = Unix.open_process command in
closer to_command ;
try while true do
print_endline (input_line from_command) ;
done
with End_of_file -> () ;
ignore (Unix.close_process (from_command,to_command)) ;;
let _ = String.create (Sys.max_string_length) in
run (fun to_command -> Unix.close (Unix.descr_of_out_channel to_command)) "echo 1" ;
run (fun to_command -> Unix.close (Unix.descr_of_out_channel to_command)) "echo 2" ;
run (fun to_command -> close_out to_command) "echo 3" ;
run (fun to_command -> close_out to_command) "echo 4" ;
[-- Attachment #1.3: nosegfault.ml --]
[-- Type: text/plain, Size: 645 bytes --]
let run closer command =
let (from_command,to_command) = Unix.open_process command in
closer to_command ;
try while true do
print_endline (input_line from_command) ;
done
with End_of_file -> () ;
ignore (Unix.close_process (from_command,to_command)) ;;
run (fun to_command -> Unix.close (Unix.descr_of_out_channel to_command)) "echo 1" ;
run (fun to_command -> Unix.close (Unix.descr_of_out_channel to_command)) "echo 2" ;
run (fun to_command -> close_out to_command) "echo 3" ;
run (fun to_command -> close_out to_command) "echo 4" ;
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] Segfault with close_out in ocaml 3.09.2
2007-07-01 18:41 Segfault with close_out in ocaml 3.09.2 Jørgen Hermanrud Fjeld
@ 2007-07-02 13:25 ` Martin Jambon
0 siblings, 0 replies; 2+ messages in thread
From: Martin Jambon @ 2007-07-02 13:25 UTC (permalink / raw)
To: Jørgen Hermanrud Fjeld; +Cc: caml-list
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1280 bytes --]
On Sun, 1 Jul 2007, Jørgen Hermanrud Fjeld wrote:
> Hi!
> I can provoke a segfault with close_out, and suspect a bug somewhere in
> ocaml 3.09.2 or the Pervasives module of ocaml 3.09.2, as shipping with
> Ubuntu feisty.
It's probably this bug:
http://caml.inria.fr/mantis/view.php?id=4039
Martin
>
> To reproduce, save the attached files, use ocaml 3.09.2 and run
> ####
> ocamlopt unix.cmxa -o nosegfault nosegfault.ml
> ocamlopt unix.cmxa -o segfault segfault.ml
> ./nosegfault ; ./segfault
> ####
>
> The difference between segfault.ml and nosegfault.ml is the allocation
> of a large string
> ####
> let _ = String.create (Sys.max_string_length) in
> ####
>
> The bug appears for the second call to close_out.
>
> When I use Unix.close, there is no problem.
>
> The original code where the testcase is derived form ran fine when
> compiled with ocaml 3.08.
>
> When I use ocaml 3.10.0 the problem is gone.
>
> If someone can help discover why the segfault appears that would be
> nice.
> Since the bug disappears in ocaml 3.10, the bug is probably fixed,
> which one can check when the cause of the segfault is discovered.
>
>
> --
> Sincerely | Homepage:
> Jørgen | http://www.hex.no/jhf
> | Public GPG key:
> | http://www.hex.no/jhf/key.txt
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-07-02 13:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-01 18:41 Segfault with close_out in ocaml 3.09.2 Jørgen Hermanrud Fjeld
2007-07-02 13:25 ` [Caml-list] " Martin Jambon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox