From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_FAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 05512BC69 for ; Sun, 1 Jul 2007 20:41:36 +0200 (CEST) Received: from h2o.hex.no (93.80-203-243.nextgentel.com [80.203.243.93]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l61IfZsW006990 for ; Sun, 1 Jul 2007 20:41:35 +0200 Received: from localhost (h2o.hex.no [80.203.243.93]) by h2o.hex.no (Postfix) with ESMTP id 7227443F8CA for ; Sun, 1 Jul 2007 20:41:18 +0200 (CEST) Date: Sun, 1 Jul 2007 20:41:17 +0200 From: =?iso-8859-1?Q?J=F8rgen?= Hermanrud Fjeld To: caml-list@inria.fr Subject: Segfault with close_out in ocaml 3.09.2 Message-ID: <20070701184116.GA25644@hex.no> Mail-Followup-To: caml-list@inria.fr MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="/e2eDi0V/xtL+Mc8" Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) X-Miltered: at concorde with ID 4687F55F.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; segfault:01 ocaml:01 segfault:01 bug:01 ocaml:01 pervasives:01 ocamlopt:01 cmxa:01 ocamlopt:01 cmxa:01 bug:01 gpg:01 endline:01 endline:01 ubuntu:98 X-Attachments: name="segfault.ml" name="nosegfault.ml" type="application/pgp-signature" name="signature.asc" --/e2eDi0V/xtL+Mc8 Content-Type: multipart/mixed; boundary="neYutvxvOLaeuPCA" Content-Disposition: inline --neYutvxvOLaeuPCA Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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=20 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 =2E/nosegfault ; ./segfault #### The difference between segfault.ml and nosegfault.ml is the allocation=20 of a large string #### let _ =3D 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,=20 which one can check when the cause of the segfault is discovered. --=20 Sincerely | Homepage: J=F8rgen | http://www.hex.no/jhf | Public GPG key: | http://www.hex.no/jhf/key.txt --neYutvxvOLaeuPCA Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="segfault.ml" Content-Transfer-Encoding: quoted-printable let run closer command =3D=20 let (from_command,to_command) =3D Unix.open_process command in closer to_command ; try while true do=20 print_endline (input_line from_command) ; done with End_of_file -> () ; ignore (Unix.close_process (from_command,to_command)) ;; let _ =3D 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" ; --neYutvxvOLaeuPCA Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="nosegfault.ml" Content-Transfer-Encoding: quoted-printable let run closer command =3D=20 let (from_command,to_command) =3D Unix.open_process command in closer to_command ; try while true do=20 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" ; --neYutvxvOLaeuPCA-- --/e2eDi0V/xtL+Mc8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFGh/VM9jvTqPy5VsoRAthVAJ9lUP7MoDhXDdm6cdV2ffWYu42hCgCeMdsH +mj2tY6+xWsSOu8KnGzpgJ4= =Hs5G -----END PGP SIGNATURE----- --/e2eDi0V/xtL+Mc8--