From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA17342; Tue, 19 Feb 2002 15:34:31 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA16889 for ; Tue, 19 Feb 2002 15:34:30 +0100 (MET) Received: from dpt-info.u-strasbg.fr (dpt-info.u-strasbg.fr [130.79.44.193]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g1JEYTj20416 for ; Tue, 19 Feb 2002 15:34:29 +0100 (MET) Received: (from luther@localhost) by dpt-info.u-strasbg.fr (8.9.3/8.9.3) id PAA02998; Tue, 19 Feb 2002 15:35:19 +0100 Date: Tue, 19 Feb 2002 15:35:19 +0100 From: Sven To: Warp Cc: OCaml Subject: Re: [Caml-list] Bug value Message-ID: <20020219153519.A2931@dpt-info.u-strasbg.fr> References: <00f901c1b93e$e95ad6c0$3c00a8c0@warp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <00f901c1b93e$e95ad6c0$3c00a8c0@warp>; from warplayer@free.fr on Tue, Feb 19, 2002 at 01:13:59PM +0100 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, Feb 19, 2002 at 01:13:59PM +0100, Warp wrote: > Is the following code : > > let read_fdata file = > let id = (input_value file : fid) in > let infos = (input_value file : finfos) in > { > id = id; > infos = infos; > childs = clist; > deps = dlist; > } > > equivalent to : > > let read_fdata file = > { > id = (input_value file : fid); > infos = (input_value file : finfos); > } > > ? > Because the first one got no problem while the second one is causing a fatal > bug at run-time when I try to access the struct Mmm, my guess is that the first one is done in order, while the second one is done from the last field to the first, not sure though. As such, it can happen that you did write a fid (which is an int) while you try to read a finfos first, and thus this cause problems. You could try inverting the order of the id = and infos =, but again, this is not guaranteed to work on all implementations of ocaml (or even between different versions), and as thus is discouraged, i think. The file ios are insecure, which cause the problem to be detected at runtime, and not at compile time. There was work from Jun about securing this kind of thing, but i guess it never made it into the official release of ocaml. Friendly, Sven Luther ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners