PARI/GP Bug report logs - #1230
Grave error in bezout on MacOs X Lion

Package: pari-stable; Maintainer for pari-stable is Aurel Page <aurel.page@normalesup.org>; Source for pari-stable is src:pari-stable.

Reported by: Antoine Joux <Antoine.Joux@prism.uvsq.fr>

Date: Thu, 4 Aug 2011 19:03:02 UTC

Severity: grave

Merged with 1415, 1433, 1455

Done: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>

Bug is archived. No further changes may be made.

Toggle useless messages

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


Report forwarded to bug-submit-list@pari.math.u-bordeaux.fr, Karim.Belabas@math.u-bordeaux.fr:
Bug#1230; Package pari-stable. (full text, mbox, link).


Acknowledgement sent to Antoine Joux <Antoine.Joux@prism.uvsq.fr>:
New Bug report received and forwarded. Copy sent to Karim.Belabas@math.u-bordeaux.fr. (full text, mbox, link).


Message #5 received at submit@pari.math.u-bordeaux.fr (full text, mbox, reply):

From: Antoine Joux <Antoine.Joux@prism.uvsq.fr>
To: submit@pari.math.u-bordeaux.fr
Subject: Grave error in bezout on MacOs X Lion
Date: Thu, 4 Aug 2011 20:38:38 +0200
Package: pari-stable
Version: 2.5.0
Severity: Grave 

bezout has an incorrect behavior which vanishes when gp is compiled in debug mode.
I isolated one example, but there are many others. The bezout function says that gcd(2,7)=2 !

This of course has consequence on all functions that use modular arithmetic. I first encountered the problem with "chinese" and elliptic curves.


Here is pari's output:

                  GP/PARI CALCULATOR Version 2.5.0 (released)
          i386 running darwin (x86-64/GMP-5.0.2 kernel) 64-bit version
compiled: Aug  4 2011, gcc-4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
                 (readline v6.2 enabled, extended help enabled)

                     Copyright (C) 2000-2011 The PARI Group

PARI/GP is free software, covered by the GNU General Public License, and comes 
WITHOUT ANY WARRANTY WHATSOEVER.

Type ? for help, \q to quit.
Type ?12 for how to get moral (and possibly technical) support.

parisize = 8000000, primelimit = 500509
? bezout(7,2)
%1 = [0, 1, 2]

INCORRECT
-----------------------------
The same in debug mode:

                  GP/PARI CALCULATOR Version 2.5.0 (released)
   i386 running darwin (x86-64/GMP-5.0.2 kernel) 64-bit version -- debugging
compiled: Aug  4 2011, gcc-4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
                 (readline v6.2 enabled, extended help enabled)

                     Copyright (C) 2000-2011 The PARI Group

PARI/GP is free software, covered by the GNU General Public License, and comes 
WITHOUT ANY WARRANTY WHATSOEVER.

Type ? for help, \q to quit.
Type ?12 for how to get moral (and possibly technical) support.

parisize = 8000000, primelimit = 500509
? bezout(7,2)
%1 = [1, -3, 1]

CORRECT

--------------------------------





Information forwarded to bug-submit-list@pari.math.u-bordeaux.fr, Karim.Belabas@math.u-bordeaux.fr:
Bug#1230; Package pari-stable. (full text, mbox, link).


Acknowledgement sent to Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>:
Extra info received and forwarded to list. Copy sent to Karim.Belabas@math.u-bordeaux.fr. (full text, mbox, link).


Message #10 received at 1230@pari.math.u-bordeaux.fr (full text, mbox, reply):

From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
To: Antoine Joux <Antoine.Joux@prism.uvsq.fr>, 1230@pari.math.u-bordeaux.fr
Subject: Re: Bug#1230: Grave error in bezout on MacOs X Lion
Date: Thu, 4 Aug 2011 23:17:55 +0200
On Thu, Aug 04, 2011 at 08:38:38PM +0200, Antoine Joux wrote:
> Package: pari-stable
> Version: 2.5.0
> Severity: Grave 
> 
> bezout has an incorrect behavior which vanishes when gp is compiled in debug mode.
> I isolated one example, but there are many others. The bezout function says that gcd(2,7)=2 !

Hello Antoine,

Does 'make bench' even succeed ?

All the evidence point to a compiler problem. Indeed the compiler version you mention
is not able to compile PARI without GMP support. 

You can try to build with
make clean;
make "CFLAGS=-O0 -Wall -fno-strict-aliasing -fomit-frame-pointer" 'KERNELCFLAGS=' gp

to see if this fix the compiler issue.

Cheers,
Bill.



Information forwarded to bug-submit-list@pari.math.u-bordeaux.fr, Karim.Belabas@math.u-bordeaux.fr:
Bug#1230; Package pari-stable. (full text, mbox, link).


Acknowledgement sent to Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>:
Extra info received and forwarded to list. Copy sent to Karim.Belabas@math.u-bordeaux.fr. (full text, mbox, link).


Message #15 received at 1230@pari.math.u-bordeaux.fr (full text, mbox, reply):

From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
To: Antoine Joux <Antoine.Joux@prism.uvsq.fr>
Cc: 1230@pari.math.u-bordeaux1.fr
Subject: Re: Bug#1230: Grave error in bezout on MacOs X Lion
Date: Fri, 5 Aug 2011 12:16:55 +0200
On Thu, Aug 04, 2011 at 11:27:51PM +0200, Antoine Joux wrote:
> Hi Bill,
> 
> No, "make bench" does not succeed !
> 
> 
> Your compile command fixes the problem (and the debug mode also does it). So yes it is probably an optimizer problem.
> What do you do in this case ? Report to the compiler maintainer or just ignore ?

I try to get the attention of the compier maintainers, but it is not always easy.

> By the way, is there a configure option to use a different compiler (already installed in my system) ?

Yes, do
CC=/path/to/compiler ./Configure

Cheers,
Bill.



Merged 1230 1433. Request was from Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr> to control@pari.math.u-bordeaux.fr. (full text, mbox, link).


Merged 1230 1433 1455 Request was from Bill Allombert <Bill.Allombert@math.u-bordeaux.fr> to control@pari.math.u-bordeaux.fr. (Tue, 13 Aug 2013 20:48:02 GMT) (full text, mbox, link).


Merged 1230 1415 1433 1455 Request was from Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr> to control@pari.math.u-bordeaux.fr. (Thu, 05 Sep 2013 15:18:01 GMT) (full text, mbox, link).


Information forwarded to bug-submit-list@pari.math.u-bordeaux.fr, Karim.Belabas@math.u-bordeaux.fr:
Bug#1230; Package pari-stable. (Wed, 18 Dec 2013 13:18:01 GMT) (full text, mbox, link).


Acknowledgement sent to Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>:
Extra info received and forwarded to list. Copy sent to Karim.Belabas@math.u-bordeaux.fr. (Wed, 18 Dec 2013 13:18:01 GMT) (full text, mbox, link).


Message #26 received at 1230@pari.math.u-bordeaux.fr (full text, mbox, reply):

From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
To: Antoine Joux <Antoine.Joux@prism.uvsq.fr>, 1230@pari.math.u-bordeaux.fr
Subject: Re: Bug#1230: Grave error in bezout on MacOs X Lion
Date: Wed, 18 Dec 2013 14:13:58 +0100
On Thu, Aug 04, 2011 at 11:17:55PM +0200, Bill Allombert wrote:
> On Thu, Aug 04, 2011 at 08:38:38PM +0200, Antoine Joux wrote:
> > Package: pari-stable
> > Version: 2.5.0
> > Severity: Grave 
> > 
> > bezout has an incorrect behavior which vanishes when gp is compiled in debug mode.
> > I isolated one example, but there are many others. The bezout function says that gcd(2,7)=2 !
> 
> Hello Antoine,
> 
> Does 'make bench' even succeed ?
> 
> All the evidence point to a compiler problem. Indeed the compiler version you mention
> is not able to compile PARI without GMP support. 
> 
> You can try to build with
> make clean;
> make "CFLAGS=-O0 -Wall -fno-strict-aliasing -fomit-frame-pointer" 'KERNELCFLAGS=' gp
> 
> to see if this fix the compiler issue.

I finally found a fix (at least for snow leopard), see
<http://pari.math.u-bordeaux.fr/archives/pari-dev-1312/msg00021.html>

If one change the definition of divll in src/kernel/x86_64/asm0.h

#define divll(a,b) \
__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
   __asm__ ("divq %4" \
        : "=a" /* %eax */ (__value), "=&d" /* %edx */ (hiremainder) \
                                     ^^^^^
        : "0" /* %eax */ (__arg1), "1" /* %edx */ (hiremainder), "mr" (__arg2)); \
   __value; \
})

by replacing "=&d" by "=d", then GP works fine (make test-all succeed).

Cheers,
Bill.



Reply sent to Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>:
You have taken responsibility. (Tue, 25 Mar 2014 11:03:01 GMT) (full text, mbox, link).


Notification sent to Antoine Joux <Antoine.Joux@prism.uvsq.fr>:
Bug acknowledged by developer. (Tue, 25 Mar 2014 11:03:01 GMT) (full text, mbox, link).


Message #31 received at 1230-done@pari.math.u-bordeaux.fr (full text, mbox, reply):

From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
To: 1230-done@pari.math.u-bordeaux.fr
Cc: Antoine Joux <Antoine.Joux@prism.uvsq.fr>
Subject: Re: Bug#1230: Grave error in bezout on MacOs X Lion
Date: Tue, 25 Mar 2014 11:49:49 +0100
On Wed, Dec 18, 2013 at 02:13:58PM +0100, Bill Allombert wrote:
> On Thu, Aug 04, 2011 at 11:17:55PM +0200, Bill Allombert wrote:
> > On Thu, Aug 04, 2011 at 08:38:38PM +0200, Antoine Joux wrote:
> > > Package: pari-stable
> > > Version: 2.5.0
> > > Severity: Grave 
> > > 
> > > bezout has an incorrect behavior which vanishes when gp is compiled in debug mode.
> > > I isolated one example, but there are many others. The bezout function says that gcd(2,7)=2 !
> > 
> > Hello Antoine,
> > 
> > Does 'make bench' even succeed ?
> > 
> > All the evidence point to a compiler problem. Indeed the compiler version you mention
> > is not able to compile PARI without GMP support. 
> > 
> > You can try to build with
> > make clean;
> > make "CFLAGS=-O0 -Wall -fno-strict-aliasing -fomit-frame-pointer" 'KERNELCFLAGS=' gp
> > 
> > to see if this fix the compiler issue.
> 
> I finally found a fix (at least for snow leopard), see
> <http://pari.math.u-bordeaux.fr/archives/pari-dev-1312/msg00021.html>
> 
> If one change the definition of divll in src/kernel/x86_64/asm0.h
> 
> #define divll(a,b) \
> __extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \
>    __asm__ ("divq %4" \
>         : "=a" /* %eax */ (__value), "=&d" /* %edx */ (hiremainder) \
>                                      ^^^^^
>         : "0" /* %eax */ (__arg1), "1" /* %edx */ (hiremainder), "mr" (__arg2)); \
>    __value; \
> })
> 
> by replacing "=&d" by "=d", then GP works fine (make test-all succeed).

PARI 2.7.0 was released with this fix, so I close this report.

Cheers,
Bill.



Reply sent to Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>:
You have taken responsibility. (Tue, 25 Mar 2014 11:03:01 GMT) (full text, mbox, link).


Notification sent to "Basak, Tathagata [MATH]" <tathagat@iastate.edu>:
Bug acknowledged by developer. (Tue, 25 Mar 2014 11:03:01 GMT) (full text, mbox, link).


Reply sent to Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>:
You have taken responsibility. (Tue, 25 Mar 2014 11:03:01 GMT) (full text, mbox, link).


Notification sent to David Kotz <kotz.david8@gmail.com>:
Bug acknowledged by developer. (Tue, 25 Mar 2014 11:03:01 GMT) (full text, mbox, link).


Reply sent to Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>:
You have taken responsibility. (Tue, 25 Mar 2014 11:03:01 GMT) (full text, mbox, link).


Notification sent to "Zickert, Christian" <zickert@math.umd.edu>:
Bug acknowledged by developer. (Tue, 25 Mar 2014 11:03:01 GMT) (full text, mbox, link).


Bug archived. Request was from Debbugs Internal Request <allomber@math.u-bordeaux.fr> to internal_control@pari.math.u-bordeaux.fr. (Wed, 23 Apr 2014 05:24:01 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


Bill Allombert <allomber@math.u-bordeaux.fr>. Last modified: Thu Apr 25 07:15:33 2024; Machine Name: pari

PARI/GP Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.