From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 1DF787EEEB for ; Tue, 4 Dec 2012 16:20:22 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.84,215,1355094000"; d="scan'208";a="184572603" Received: from macadam.inria.fr (HELO [192.168.1.3]) ([128.93.8.130]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA; 04 Dec 2012 16:20:21 +0100 Mime-Version: 1.0 (Apple Message framework v1283) Content-Type: multipart/mixed; boundary="Apple-Mail=_4727213B-E306-495B-A9C4-E2822E5ACA2E" From: Damien Doligez In-Reply-To: Date: Tue, 4 Dec 2012 16:20:21 +0100 Cc: caml users Message-Id: References: To: Lin Hong X-Mailer: Apple Mail (2.1283) Subject: Re: [Caml-list] Segmentation fault from Array.append Ocaml 4.0.x -- walk around --Apple-Mail=_4727213B-E306-495B-A9C4-E2822E5ACA2E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 Hello Lin Hong, I have found a bug in the C code for Array.append. A patch against 4.00.1 is attached to this mail. I couldn't make a small repro case for this bug, so I would appreciate if you could try this patch an tell me whether it fixes the problem for you. Cheers, -- Damien On 2012-11-28, at 21:02, Lin Hong wrote: > Hi, all >=20 > we avoid the problem by creating our version of Array.append. Our version= of Array.append looks just like the one from Ocaml 3.12, instead of operat= ing directly on memory, we call get & set function to do the job. >=20 > still have no idea why Array.append from Ocaml4.0.x cause the seg fault, = but we will stick to our walk around solution till new version come out. >=20 > Cheers, > Lin Hong > American Museum of Natural History > POY website : > https://code.google.com/p/poy/ > http://research.amnh.org/scicomp/scripts/download.php >=20 > ________________________________________ > From: caml-list-request@inria.fr [caml-list-request@inria.fr] on behalf o= f Lin Hong [lhong@amnh.org] > Sent: Monday, November 19, 2012 12:04 PM > To: Damien Doligez; caml users > Subject: RE: [Caml-list] Segmentation fault from Array.append >=20 > Hi, >=20 > we recompiled Ocaml with debug version of runtime, then compiled our prog= ram into byte code, run the same data-set , the problem disappear. >=20 > but with native version of our program, the segmentation fault still show= s. >=20 > As for native version, if we run it with Gc.compact() being called around= Array.append, the problem won't show. >=20 > also gdb point us to some major_slice() function, so we call Gc.major_sli= ce() before Array.append, this also make the problem disappear. >=20 >=20 > still don't know what's going on here, any other suggestions are highly a= ppreciated. >=20 >=20 > Thanks. >=20 > Cheers, > Lin Hong > American Museum of Natural History > POY website : > https://code.google.com/p/poy/ > http://research.amnh.org/scicomp/scripts/download.php >=20 > ________________________________________ > From: caml-list-request@inria.fr [caml-list-request@inria.fr] on behalf o= f Damien Doligez [damien.doligez@inria.fr] > Sent: Wednesday, October 17, 2012 9:33 AM > To: caml users > Subject: Re: [Caml-list] Segmentation fault from Array.append >=20 > Hello, >=20 >> From: Daniel B=FCnzli [daniel.buenzli@erratique.ch] >>=20 >> http://rwmj.wordpress.com/2010/01/22/tip-tracking-down-ocaml-heap-corrup= tors/ >=20 >=20 > I have posted a comment to that blog. For the archive, here's what it sa= ys: >=20 > Starting with OCaml 4.00.0, there is an easy way to activate the debug ve= rsion of the runtime: >=20 > 1. configure OCaml with "-with-debug-runtime" > 2. compile and install OCaml > 3. compile your program with "-runtime-variant d" >=20 > This will compile your program with a version of the runtime which has as= sertions all over the place, and does a thorough check of the heap structur= e at each major GC (and at each compaction). If you then follow Rich=92s ad= vice, you should be able to narrow down the source of the heap corruption q= uite easily. >=20 > -- Damien >=20 >=20 > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >=20 > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs --Apple-Mail=_4727213B-E306-495B-A9C4-E2822E5ACA2E Content-Disposition: attachment; filename=0000-array-append-segfault.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0000-array-append-segfault.patch" Content-Transfer-Encoding: 7bit Index: byterun/array.c =================================================================== --- byterun/array.c (revision 13107) +++ byterun/array.c (working copy) @@ -321,11 +321,12 @@ count--, src++, pos++) { caml_initialize(&Field(res, pos), *src); } - /* Many caml_initialize in a row can create a lot of old-to-young - refs. Give the minor GC a chance to run if it needs to. */ - res = caml_check_urgent_gc(res); } Assert(pos == size); + + /* Many caml_initialize in a row can create a lot of old-to-young + refs. Give the minor GC a chance to run if it needs to. */ + res = caml_check_urgent_gc(res); } CAMLreturn (res); } --Apple-Mail=_4727213B-E306-495B-A9C4-E2822E5ACA2E--