[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#403848: ocaml: segfault on (unavoidably) closing a channel twice



Package: ocaml
Version: 3.09.2-7
Severity: important
Tags: patch

This is exactly bug http://caml.inria.fr/mantis/view.php?id=4039 and it
arises is several situations:

 - http://caml.inria.fr/pub/ml-archives/caml-list/2006/08/db4d1bda007d884bfed86ef086e9463e.en.html

 - I am using Unix.open_process_full to open stdout,stdin,stderr.
   stdin needs to be closed early, but that causes a segfault when
   close_process_full is called later.

The concise fix is in the attached patch and is apparently already in
the upstream 3.09 bugfix branch, and 3.10.

Is it too late to get this fix into etch?

-- System Information:
Debian Release: 4.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-1-686
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages ocaml depends on:
ii  ocaml-base [ocaml-base-3.09.2 3.09.2-7   Runtime system for ocaml bytecode 
ii  ocaml-nox [ocaml-nox-3.09.2]  3.09.2-7   ML language implementation with a 

ocaml recommends no packages.

-- no debconf information
diff -rupax ocamlc -x ocamllex ocaml-3.09.2/byterun/io.c ocaml-3.09.3~rc1/byterun/io.c
--- ocaml-3.09.2/byterun/io.c	2006-03-22 23:59:58.000000000 +1100
+++ ocaml-3.09.3~rc1/byterun/io.c	2006-06-09 00:57:59.000000000 +1000
@@ -11,7 +11,7 @@
 /*                                                                     */
 /***********************************************************************/
 
-/* $Id: io.c,v 1.72.2.1 2006/03/22 12:59:58 doligez Exp $ */
+/* $Id: io.c,v 1.72.2.2 2006/06/08 14:57:59 xleroy Exp $ */
 
 /* Buffered input/output. */
 
@@ -534,7 +534,7 @@ CAMLprim value caml_ml_flush_partial(val
   struct channel * channel = Channel(vchannel);
   int res;
 
-  if (channel->fd == -1) return Val_true;
+  if (channel->fd == -1) CAMLreturn (Val_true);
   Lock(channel);
   res = caml_flush_partial(channel);
   Unlock(channel);
@@ -546,7 +546,7 @@ CAMLprim value caml_ml_flush(value vchan
   CAMLparam1 (vchannel);
   struct channel * channel = Channel(vchannel);
 
-  if (channel->fd == -1) return Val_unit;
+  if (channel->fd == -1) CAMLreturn (Val_unit);
   Lock(channel);
   caml_flush(channel);
   Unlock(channel);
diff -rupax ocamlc -x ocamllex ocaml-3.09.2/byterun/memory.h ocaml-3.09.3~rc1/byterun/memory.h
--- ocaml-3.09.2/byterun/memory.h	2005-10-15 02:40:48.000000000 +1000
+++ ocaml-3.09.3~rc1/byterun/memory.h	2006-07-25 19:13:16.000000000 +1000
@@ -11,7 +11,7 @@
 /*                                                                     */
 /***********************************************************************/
 
-/* $Id: memory.h,v 1.54 2005/10/14 16:40:48 xleroy Exp $ */
+/* $Id: memory.h,v 1.54.2.3 2006/07/25 09:13:16 doligez Exp $ */
 
 /* Allocation macros and functions */
 
@@ -278,8 +278,9 @@ CAMLextern struct caml__roots_block *cam
 }while (0)
 
 #define CAMLreturn(result) do{ \
+  value caml__temp_result = (result); \
   caml_local_roots = caml__frame; \
-  return (result); \
+  return (caml__temp_result); \
 }while(0)
 
 #define CAMLnoreturn ((void) caml__frame)

Reply to: