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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 0BA417ED5C for ; Wed, 1 Aug 2012 23:24:08 +0200 (CEST) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=pra; client-ip=212.227.17.8; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=mailfrom; client-ip=212.227.17.8; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of postmaster@moutng.kundenserver.de designates 212.227.17.8 as permitted sender) identity=helo; client-ip=212.227.17.8; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="postmaster@moutng.kundenserver.de"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtIBAMWdGVDU4xEIjWdsb2JhbAArGqd1kRwiAQEBAQkJCwkSBSSCIAEBBAE6NBAeCQQBAQ5dCQoIBhMJCYdsAwYKBymbKZgPA4lYFIs1hwkDjUKJGYgXgVoIh2GBVAc X-IronPort-AV: E=Sophos;i="4.77,696,1336341600"; d="scan'208";a="152240066" Received: from moutng.kundenserver.de ([212.227.17.8]) by mail4-smtp-sop.national.inria.fr with ESMTP; 01 Aug 2012 23:24:07 +0200 Received: from office1.lan.sumadev.de (dslb-094-219-223-014.pools.arcor-ip.net [94.219.223.14]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0Ln0qf-1TPwL512Ev-00hJhj; Wed, 01 Aug 2012 23:24:06 +0200 Received: from samsung (ip-92-50-84-130.unitymediagroup.de [92.50.84.130]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id C907EC00D0 for ; Wed, 1 Aug 2012 23:24:05 +0200 (CEST) Date: Wed, 01 Aug 2012 23:24:05 +0200 From: Gerd Stolpmann Reply-To: Gerd Stolpmann To: Mailing OCaML In-Reply-To: X-Mailer: Balsa 2.4.11 Message-Id: <1343856245.3275.4@samsung> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; DelSp=Yes; Format=Flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-Provags-ID: V02:K0:CguUl5Rid6nM5bNH1IU9ojRN1s7oAGitoTZ+W1OFFCt zBAxU/NE61l3utIGWATGZQj6BlQH/53mwe+CjFUlqvv2sdZ5MD K6zneiO06t+39NOSX/v1ini7O7nS/Yp7iyfeongeOcz7shPMlc gSWMAy7pOnMGD5BqFMUM/4d8eUNWRrEFEDqIepqYryGUVanae9 7YLoKDFmkdRBtH13BqLjA//Z6NvW95XTTM7khjKgOsg6bRYSG3 J5k4IatEuh6hW4Cxka38cM3tNlQVJoi4fbDL7394qvWIxUGDxs BbvcBZa/6DlQ+d38IdVdqNJuA9Fp+C2SWz64ifYOkkk9MxSqqO yRwd/XQdcJbgFyzOvGYo= Subject: AW: [Caml-list] Segmentation fault right after caml_alloc_custom Am 01.08.2012 23:08:12 schrieb(en) Lin Hong: > Hi Gerd, >=20 > thank you for the reply. >=20 > how do we know if some value is registered as local root or not? Easy: It is your task as developer of a C external to register values,=20= =20 so if you don't do it, it is not done. > the code is long so I will just paste some of it first >=20 > in that c file, the value we tried to access but failed was also=20=20 > allocated by caml_alloc_custom(ops, size, used, max). >=20 > caml_alloc_custom (&sankoff_custom_operations_eltarr,sizeof (struct=20=20 > elt_arr)+sz, 1,alloc_custom_max); >=20 > the ops was custom_operations with all standard options as follow: >=20 > static struct custom_operations sankoff_custom_operations_eltarr =3D { > "http://www.amnh.org/poy/", > custom_finalize_default, > custom_compare_default, > custom_hash_default, > custom_serialize_default, > custom_deserialize_default > }; >=20 >=20 > the size in caml_alloc_custom is set to the full size , that is the=20=20 > data structure itself, plus everything its pointers point to. This is probably all ok. Did you use the CAMLparam and CAMLlocal macros? Gerd >=20 > we also debug with valgrind, the feed back suggest the memory we=20=20 > tried to access is indeed freed by caml gc >=20 > =3D=3D64563=3D=3D Invalid read of size 4 > =3D=3D64563=3D=3D at 0x38477B: sankoff_median_3 (in ../poy.native) > =3D=3D64563=3D=3D by 0x386125: sankoff_CAML_median_3 (in ../poy.native) > =3D=3D64563=3D=3D by 0x13177D: camlSankCS__median_3_196 (in ../poy.nat= ive) > =3D=3D64563=3D=3D Address 0x8bb0c04 is 81,108 bytes inside a block of si= ze=20=20 > 512,016 free'd > =3D=3D64563=3D=3D at 0xAFD7BF: free (vg_replace_malloc.c:325) > =3D=3D64563=3D=3D by 0x3E5AC2: caml_free_for_heap (in ../poy.native) > =3D=3D64563=3D=3D by 0x3E5C31: caml_shrink_heap (in ../poy.native) > =3D=3D64563=3D=3D by 0x3F16FC: caml_compact_heap (in ../poy.native) > =3D=3D64563=3D=3D by 0x3F1A89: caml_compact_heap_maybe (in ../poy.nati= ve) > =3D=3D64563=3D=3D by 0x3E4EBC: caml_major_collection_slice (in=20=20 > ../poy.native) > =3D=3D64563=3D=3D by 0x3E5692: caml_minor_collection (in ../poy.native) > =3D=3D64563=3D=3D by 0x3E57E0: caml_check_urgent_gc (in ../poy.native) > =3D=3D64563=3D=3D by 0x3F209C: caml_alloc_custom (in ../poy.native) >=20 >=20 >=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: Gerd Stolpmann [gerd@edgespring.com] > Sent: Wednesday, August 01, 2012 4:13 PM > To: Lin Hong > Cc: Mailing OCaML > Subject: Re: [Caml-list] Segmentation fault right after=20=20 > caml_alloc_custom >=20 > You did not send code, so we can only speculate. A reason for this > behavior could be that a value is not registered as local root, so the > GC thinks it is unused. >=20 > That you see the problem only on some platforms can be explained by=20=20 > the > different implementations of malloc, and how quickly freed memory is > really deallocated (i.e. given back to the kernel). I wouldn't give > much on this observation. >=20 > Gerd >=20 > Am 01.08.2012 22:05:19 schrieb(en) Lin Hong: > > Hi all, > > > > we have a weird problem here. In a c file, right after one call of > > 'caml_alloc_custom', some old information we have in memory is gone, > > then we have the segmentation fault because the code try to access > > those informations later. > > > > turn on debug message with OCAMLRUNPARAM, get this right before it > > crash. > > > > ...... > > $Starting new major GC cycle > > Marking 9223372036854775807 words > > Subphase =3D 10 > > Sweeping 9223372036854775807 words > > Compacting heap... > > Shrinking heap to 37696k bytes > > Shrinking heap to 36704k bytes > > Shrinking heap to 35712k bytes > > Shrinking heap to 34720k bytes > > Shrinking heap to 33728k bytes > > Shrinking heap to 32736k bytes > > Shrinking heap to 31744k bytes > > Shrinking heap to 30752k bytes > > done. > > > > is it possible that the ocaml garbage collection free memory that is > > still in use? > > > > the data cause this is kind of big, it doesn't happen right away,and > > it doesn't happen on every machine (linux with ocaml4 is fine, > > ocaml3.xx is not. mac with ocaml4 still shows the problem though). > > > > any suggestion is appreciated. > > > > > > Thanks, > > Lin > > > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > American Museum of Natural History > > POY website : > > https://code.google.com/p/poy/ > > http://research.amnh.org/scicomp/scripts/download.php > > > > -- > > Caml-list mailing list. Subscription management and archives: > > https://sympa-roc.inria.fr/wws/info/caml-list > > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > > Bug reports: http://caml.inria.fr/bin/caml-bugs > > > > >=20 >=20 > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >=20 >=20 >=20 --=20 ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de Creator of GODI and camlcity.org. Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------=