Debian Bug report logs - #707127
ocaml-base: Big_int.extract_big_int does not handle negative numbers properly

version graph

Package: ocaml-base; Maintainer for ocaml-base is Debian OCaml Maintainers <debian-ocaml-maint@lists.debian.org>; Source for ocaml-base is src:ocaml.

Reported by: Drake Wilson <drake@dasyatidae.net>

Date: Tue, 7 May 2013 17:15:02 UTC

Severity: normal

Tags: fixed-upstream

Found in version ocaml/3.12.1-4

Forwarded to http://caml.inria.fr/mantis/view.php?id=6010

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Debian OCaml Maintainers <debian-ocaml-maint@lists.debian.org>:
Bug#707127; Package ocaml-base. (Tue, 07 May 2013 17:15:06 GMT) Full text and rfc822 format available.

Acknowledgement sent to Drake Wilson <drake@dasyatidae.net>:
New Bug report received and forwarded. Copy sent to Debian OCaml Maintainers <debian-ocaml-maint@lists.debian.org>. (Tue, 07 May 2013 17:15:06 GMT) Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Drake Wilson <drake@dasyatidae.net>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: ocaml-base: Big_int.extract_big_int does not handle negative numbers properly
Date: Tue, 07 May 2013 12:09:56 -0500
Package: ocaml-base
Version: 3.12.1-4
Severity: normal

This function seems to assume that unrepresented prefix regions of
bits in a Big_int.big_int are always zero, but this is not so for
negative numbers.  The documentation explicitly states that a two's
complement representation is used for those, but see the transcript
with comments inline:

% ocaml nums.cma
        Objective Caml version 3.12.1

# open Big_int;;
# let mu = minus_big_int unit_big_int;;
val mu : Big_int.big_int = <abstr>
# let s offset count = string_of_big_int (extract_big_int mu offset count);;
val s : int -> int -> string = <fun>
# s 0 16;;
- : string = "65535"
# s 16 16;;
- : string = "65535"
# s 32 16;;
- : string = "65535"
# s 48 16;;
- : string = "65535"
  (* Okay so far... *)
# s 64 16;;
- : string = "0"
  (* Oops! *)
# s 56 16;;
- : string = "255"
  (* Function seems to think this is a 2^64-1. *)
# eq_big_int (big_int_of_int 255) (extract_big_int mu 56 16);;
- : bool = true
  (* It's not just a problem with the stringifier. *)
# eq_big_int (big_int_of_int (-1)) mu;;
- : bool = true
  (* Nor is it a problem with the earlier negation. *)

   ---> Drake Wilson

-- System Information:
Debian Release: 7.0
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.2.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages ocaml-base depends on:
ii  libc6                                   2.13-38
ii  libx11-6                                2:1.5.0-1
ii  ocaml-base-nox [ocaml-base-nox-3.12.1]  3.12.1-4
ii  tcl8.5                                  8.5.11-2
ii  tk8.5                                   8.5.11-2

ocaml-base recommends no packages.

ocaml-base suggests no packages.

-- no debconf information



Set Bug forwarded-to-address to 'http://caml.inria.fr/mantis/view.php?id=6010'. Request was from St├ęphane Glondu <glondu@debian.org> to control@bugs.debian.org. (Tue, 07 May 2013 18:03:07 GMT) Full text and rfc822 format available.

Added tag(s) fixed-upstream. Request was from bts-link-upstream@lists.alioth.debian.org to control@bugs.debian.org. (Thu, 06 Jun 2013 17:57:44 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Thu Apr 17 00:02:14 2014; Machine Name: buxtehude.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.