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 RAA21501; Mon, 29 Dec 2003 17:53:42 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA20242 for ; Mon, 29 Dec 2003 17:53:41 +0100 (MET) Received: from mallaury.noc.nerim.net (smtp-101-monday.noc.nerim.net [62.4.17.101]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hBTGreL18417 for ; Mon, 29 Dec 2003 17:53:40 +0100 (MET) Received: from inria.fr (planar.net0.nerim.net [213.41.168.102]) by mallaury.noc.nerim.net (Postfix) with ESMTP id 4261C62D36; Mon, 29 Dec 2003 17:53:38 +0100 (CET) Date: Sat, 27 Dec 2003 23:55:23 +0100 Subject: Re: [Caml-list] Problem with the old Num implementation of ocaml (fwd) (PR#1989) Content-Type: multipart/mixed; boundary=Apple-Mail-6--230757133 Mime-Version: 1.0 (Apple Message framework v553) Cc: caml-list@inria.fr, caml-bugs@pauillac.inria.fr To: Thomas Fischbacher From: Damien Doligez In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.553) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 1989:99 damien:01 damien:01 bug:01 bug:01 nat:01 nat:01 arithmetics:01 plausible:01 arith:01 arith:01 reproducible:01 3.06:01 3.07:01 X-Attachments: name="patch-fischbacher.txt" name="patch-fischbacher.txt" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk --Apple-Mail-6--230757133 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On Friday, December 19, 2003, at 11:17 AM, Thomas Fischbacher wrote: > Please note that this bug concerns the "old" Num implementation that > was > removed in a recent update. This bug is in fact in the ML part of the Num library, which is common to both the old and new Num implementations. I think it dates back to Caml Light. > The attachment will reproduce a condition where doing the same > calculation > (which is purely functional to the outside and does not use global > state > or side effects, but involves Num) many times in sequence will give > different results. This "nondeterminism" comes from using a Nat.nat with an uninitialised digit, using whatever was already in memory at that address. > arithmetics I am using? Yet to me it seems plausible that some serious > issue may have been overlooked here, since I suppose very few people > use > ratio arith (in contrast to bignum-only arith, which has applications > for, > e.g., RSA). Indeed, the bug is in the big-int part of the library (arbitrary precision signed integers). Thank you for your well-delimited bug report with a reproducible test case. It was rather easy to find the bug with it. I enclose a patch, which should work on 3.06 and on 3.07pl2. -- Damien --Apple-Mail-6--230757133 Content-Disposition: attachment; filename=patch-fischbacher.txt Content-Transfer-Encoding: 7bit Content-Type: text/plain; x-unix-mode=0664; name="patch-fischbacher.txt" *** otherlibs/num/big_int.ml.old Sat Dec 27 23:45:12 2003 --- otherlibs/num/big_int.ml Sat Dec 27 23:38:44 2003 *************** *** 178,183 **** --- 178,184 ---- if i = monster_int then let res = create_nat size_res in blit_nat res 0 (bi.abs_value) 0 size_bi; + set_digit_nat res size_bi 0; mult_digit_nat res 0 size_res (bi.abs_value) 0 size_bi (nat_of_int biggest_int) 0; { sign = - (sign_big_int bi); --Apple-Mail-6--230757133 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed --Apple-Mail-6--230757133-- ------------------- 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