From: Damien Doligez <damien.doligez@inria.fr>
To: Thomas Fischbacher <Thomas.Fischbacher@Physik.Uni-Muenchen.DE>
Cc: caml-list@inria.fr, caml-bugs@pauillac.inria.fr
Subject: Re: [Caml-list] Problem with the old Num implementation of ocaml (fwd) (PR#1989)
Date: Sat, 27 Dec 2003 23:55:23 +0100 [thread overview]
Message-ID: <C0E17D5E-38BF-11D8-80E6-00039310CAE8@inria.fr> (raw)
In-Reply-To: <Pine.LNX.4.58.0312191113120.11483@seekar.cip.physik.uni-muenchen.de>
[-- Attachment #1: Type: text/plain, Size: 1254 bytes --]
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
[-- Attachment #2: patch-fischbacher.txt --]
[-- Type: text/plain, Size: 499 bytes --]
*** 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);
[-- Attachment #3: Type: text/plain, Size: 1 bytes --]
next prev parent reply other threads:[~2003-12-29 16:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-19 10:17 [Caml-list] Problem with the old Num implementation of ocaml (fwd) Thomas Fischbacher
2003-12-27 22:55 ` Damien Doligez [this message]
2003-12-30 11:25 ` [Caml-list] Problem with the Num implementation Christophe Raffalli
2004-01-06 9:46 ` [Caml-list] Problem with the old Num implementation of ocaml (fwd) (PR#1989) Thomas Fischbacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C0E17D5E-38BF-11D8-80E6-00039310CAE8@inria.fr \
--to=damien.doligez@inria.fr \
--cc=Thomas.Fischbacher@Physik.Uni-Muenchen.DE \
--cc=caml-bugs@pauillac.inria.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox