PARI/GP Bug report logs - #1237
undefined behaviour in pari_init_parser

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

Reported by: Julian Taylor <jtaylor.debian@googlemail.com>

Date: Wed, 31 Aug 2011 15:33:08 UTC

Severity: normal

Done: Bill Allombert <Bill.Allombert@math.u-bordeaux1.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#1237; Package pari. (full text, mbox, link).


Acknowledgement sent to Julian Taylor <jtaylor.debian@googlemail.com>:
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: Julian Taylor <jtaylor.debian@googlemail.com>
To: submit@pari.math.u-bordeaux.fr
Cc: ballombe@debian.org
Subject: undefined behaviour in pari_init_parser
Date: Wed, 31 Aug 2011 17:27:01 +0200
Package: pari
Version: 2.5.0

Hi,
the stack_init function used from pari_init_parser exhibits undefined behavior.
Thanks to Måns Rullgård for spotting this issue and suggesting the patch.

pari_init_parser calls stack_init with argument one and three unrelated variables
in being in global/thread-local memory:
src/language/parsec.h:43 stack_init(&s_node,sizeof(*pari_tree),(void **)&pari_tree);

In stack init this is used:
src/headers/pariinl.h:560 stack_init(pari_stack *s, size_t size, void **data)
{
  s->offset = (char *)data-(char *)s;

here the difference between the unrelated memory location is taken which is undefined.
This leads to testsuite failures on some architectures like armel [0]m armhf [1] and sparc [2]


This patch would solves the issue by using a pointer directly instead of an offset.
With it the testsuite succeeds on armel and amd64 (more were not tested).

diff -ur pari-2.5.0.fixed/src/headers/pariinl.h pari-2.5.0.fixed/src/headers/pariinl.h
--- pari-2.5.0/src/headers/pariinl.h     2011-05-30 09:28:34.000000000 +0000
+++ pari-2.5.0.fixed/src/headers/pariinl.h  2011-08-31 14:30:34.000000000 +0000
@@ -554,12 +554,12 @@
 /**                                                                **/
 /********************************************************************/
 INLINE void **
-stack_base(pari_stack *s) { return (void **) ((char *)s+s->offset); }
+stack_base(pari_stack *s) { return (void **) ((char *)s->offset); }
 
 INLINE void
 stack_init(pari_stack *s, size_t size, void **data)
 {
-  s->offset = (char *)data-(char *)s;
+  s->offset = data;
   *data = NULL;
   s->n = 0;
   s->alloc = 0;
diff -ur ./src/headers/paristio.h ../pari-2.5.0.fixed//src/headers/paristio.h
--- pari-2.5.0/src/headers/paristio.h    2011-05-30 09:28:34.000000000 +0000
+++ pari-2.5.0.fixed/src/headers/paristio.h 2011-08-31 14:33:16.000000000 +0000
@@ -125,7 +125,7 @@
 } hashtable;
 
 typedef struct {
-  long offset;
+  void* offset;
   long n;
   long alloc;
   size_t size;


[0] https://launchpad.net/ubuntu/+source/pari/2.5.0-1/+build/2648667
[1] http://buildd.debian-ports.org/status/package.php?p=pari&suite=sid
[2] https://buildd.debian.org/status/package.php?p=pari&suite=sid



Information forwarded to bug-submit-list@pari.math.u-bordeaux.fr, Karim.Belabas@math.u-bordeaux.fr:
Bug#1237; Package pari. (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 1237@pari.math.u-bordeaux.fr (full text, mbox, reply):

From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
To: Julian Taylor <jtaylor.debian@googlemail.com>, 1237@pari.math.u-bordeaux.fr
Subject: Re: Bug#1237: undefined behaviour in pari_init_parser
Date: Thu, 1 Sep 2011 22:22:45 +0200
On Wed, Aug 31, 2011 at 05:27:01PM +0200, Julian Taylor wrote:
> Package: pari
> Version: 2.5.0
> 
> Hi,
> the stack_init function used from pari_init_parser exhibits undefined behavior.
> Thanks to Måns Rullgård for spotting this issue and suggesting the patch.
> 
> pari_init_parser calls stack_init with argument one and three unrelated variables
> in being in global/thread-local memory:
> src/language/parsec.h:43 stack_init(&s_node,sizeof(*pari_tree),(void **)&pari_tree);
> 
> In stack init this is used:
> src/headers/pariinl.h:560 stack_init(pari_stack *s, size_t size, void **data)
> {
>   s->offset = (char *)data-(char *)s;
> 
> here the difference between the unrelated memory location is taken which is undefined.

Hello Julian,

Undefined according to what rule ? The code is only requiring the adress space to be flat
which is true on all supported platforms.

> This leads to testsuite failures on some architectures like armel [0]m armhf [1] and sparc [2]
> 
> This patch would solves the issue by using a pointer directly instead of an offset.
> With it the testsuite succeeds on armel and amd64 (more were not tested).

Unfortunately, this patch breaks the documented API and ABI. The offset was introduced
for a purpose, see the documentation of pari_stack. GP2C would not work with your patch
applied.

The optimisation issue with gcc-4.6 was reported here http://bugs.debian.org/627084 
and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140 and 
http://bugs.debian.org/635214. Test-cases are provided.

Cheers,
-- 
Bill. <ballombe@debian.org>

Imagine a large red swirl here. 



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


Acknowledgement sent to Julian Taylor <jtaylor.debian@googlemail.com>:
Extra info received and forwarded to list. Copy sent to Karim.Belabas@math.u-bordeaux.fr. (full text, mbox, link).


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

From: Julian Taylor <jtaylor.debian@googlemail.com>
To: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
Cc: 1237@pari.math.u-bordeaux.fr
Subject: Re: Bug#1237: undefined behaviour in pari_init_parser
Date: Thu, 01 Sep 2011 23:00:43 +0200
On 09/01/2011 10:22 PM, Bill Allombert wrote:
>
> Hello Julian,
>
> Undefined according to what rule ? The code is only requiring the adress space to be flat
> which is true on all supported platforms.
>

https://www.securecoding.cert.org/confluence/display/seccode/CC.+Undefined+Behavior#CC.UndefinedBehavior-ub45

Although it is possible that it is a compiler bug causing this issue, 
this behavior should be fixed somehow too.



Information forwarded to bug-submit-list@pari.math.u-bordeaux.fr, Karim.Belabas@math.u-bordeaux.fr:
Bug#1237; Package pari. (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 #20 received at 1237@pari.math.u-bordeaux.fr (full text, mbox, reply):

From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
To: Julian Taylor <jtaylor.debian@googlemail.com>
Cc: 1237@pari.math.u-bordeaux.fr
Subject: Re: Bug#1237: undefined behaviour in pari_init_parser
Date: Fri, 2 Sep 2011 18:57:38 +0200
[Message part 1 (text/plain, inline)]
On Thu, Sep 01, 2011 at 11:00:43PM +0200, Julian Taylor wrote:
> On 09/01/2011 10:22 PM, Bill Allombert wrote:
> >
> >Hello Julian,
> >
> >Undefined according to what rule ? The code is only requiring the adress space to be flat
> >which is true on all supported platforms.
> >
> 
> https://www.securecoding.cert.org/confluence/display/seccode/CC.+Undefined+Behavior#CC.UndefinedBehavior-ub45

Rule ARR36-C is quite excessive: for example it disallows taking the difference
of pointers inside the same malloc'ed block. PARI stack management has always
required this functionality.

> Although it is possible that it is a compiler bug causing this
> issue, this behavior should be fixed somehow too.

Well, you can try the attached patch which work around the compiler issue without
breaking the ABI (tested on sparc).

Cheers,
Bill.
[patch (text/plain, attachment)]

Information forwarded to bug-submit-list@pari.math.u-bordeaux.fr, Karim.Belabas@math.u-bordeaux.fr:
Bug#1237; Package pari. (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 #25 received at 1237@pari.math.u-bordeaux.fr (full text, mbox, reply):

From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
To: Julian Taylor <jtaylor.debian@googlemail.com>
Cc: 1237@pari.math.u-bordeaux.fr
Subject: Re: Bug#1237: undefined behaviour in pari_init_parser
Date: Tue, 13 Sep 2011 16:41:51 +0200
On Fri, Sep 02, 2011 at 06:57:38PM +0200, Bill Allombert wrote:
> On Thu, Sep 01, 2011 at 11:00:43PM +0200, Julian Taylor wrote:
> 
> Well, you can try the attached patch which work around the compiler issue without
> breaking the ABI (tested on sparc).

Hello Julian, 
I have uploaded a new Debian package that includes this patch and it was built correctly
on all platform, as you can see 
<https://buildd.debian.org/status/package.php?p=pari>
this includes armel and sparc. 
Do you still have issues on armel ?

A technical note: it is possible that stack_init is not standard compliant, but it
should be possible to rewrite it in a standard compliant according to
<http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49330#c8>
However gcc-4.6 bug PR49330 is still open so PARI would still be miscompiled.

Cheers,
Bill.



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


Acknowledgement sent to Julian Taylor <jtaylor.debian@googlemail.com>:
Extra info received and forwarded to list. Copy sent to Karim.Belabas@math.u-bordeaux.fr. (full text, mbox, link).


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

From: Julian Taylor <jtaylor.debian@googlemail.com>
To: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
Cc: 1237@pari.math.u-bordeaux.fr
Subject: Re: Bug#1237: undefined behaviour in pari_init_parser
Date: Sun, 18 Sep 2011 22:10:34 +0200
[Message part 1 (text/plain, inline)]
On 09/13/2011 04:41 PM, Bill Allombert wrote:
> On Fri, Sep 02, 2011 at 06:57:38PM +0200, Bill Allombert wrote:
>> On Thu, Sep 01, 2011 at 11:00:43PM +0200, Julian Taylor wrote:
>>
>> Well, you can try the attached patch which work around the compiler issue without
>> breaking the ABI (tested on sparc).
> 
> Hello Julian, 
> I have uploaded a new Debian package that includes this patch and it was built correctly
> on all platform, as you can see 
> <https://buildd.debian.org/status/package.php?p=pari>
> this includes armel and sparc. 
> Do you still have issues on armel ?
> 
> A technical note: it is possible that stack_init is not standard compliant, but it
> should be possible to rewrite it in a standard compliant according to
> <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49330#c8>
> However gcc-4.6 bug PR49330 is still open so PARI would still be miscompiled.
> 
> Cheers,
> Bill.

unfortunately it still fails with the same issue in my qemu armel chroot
on ubuntu oneiric which has pretty much the same gcc version as debian
(4.6-9ubuntu3).
I don't understand why.

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-submit-list@pari.math.u-bordeaux.fr, Karim.Belabas@math.u-bordeaux.fr:
Bug#1237; Package pari. (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 #35 received at 1237@pari.math.u-bordeaux.fr (full text, mbox, reply):

From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
To: Julian Taylor <jtaylor.debian@googlemail.com>
Cc: 1237@pari.math.u-bordeaux.fr
Subject: Re: Bug#1237: undefined behaviour in pari_init_parser
Date: Sun, 18 Sep 2011 23:47:54 +0200
On Sun, Sep 18, 2011 at 10:10:34PM +0200, Julian Taylor wrote:
> On 09/13/2011 04:41 PM, Bill Allombert wrote:
> > On Fri, Sep 02, 2011 at 06:57:38PM +0200, Bill Allombert wrote:
> >> On Thu, Sep 01, 2011 at 11:00:43PM +0200, Julian Taylor wrote:
> >>
> >> Well, you can try the attached patch which work around the compiler issue without
> >> breaking the ABI (tested on sparc).
> > 
> > Hello Julian, 
> > I have uploaded a new Debian package that includes this patch and it was built correctly
> > on all platform, as you can see 
> > <https://buildd.debian.org/status/package.php?p=pari>
> > this includes armel and sparc. 
> > Do you still have issues on armel ?
> > 
> > A technical note: it is possible that stack_init is not standard compliant, but it
> > should be possible to rewrite it in a standard compliant according to
> > <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49330#c8>
> > However gcc-4.6 bug PR49330 is still open so PARI would still be miscompiled.
> > 
> > Cheers,
> > Bill.
> 
> unfortunately it still fails with the same issue in my qemu armel chroot
> on ubuntu oneiric which has pretty much the same gcc version as debian
> (4.6-9ubuntu3).
> I don't understand why.

Can you check with the debugger whether it is not a different instance of the same
issue ? The function pari_init_parser has a similar issue.

Cheers,
Bill.



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


Acknowledgement sent to Julian Taylor <jtaylor.debian@googlemail.com>:
Extra info received and forwarded to list. Copy sent to Karim.Belabas@math.u-bordeaux.fr. (full text, mbox, link).


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

From: Julian Taylor <jtaylor.debian@googlemail.com>
To: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
Cc: Julian Taylor <jtaylor.debian@googlemail.com>, 1237@pari.math.u-bordeaux.fr
Subject: Re: Bug#1237: undefined behaviour in pari_init_parser
Date: Mon, 19 Sep 2011 19:31:41 +0200
[Message part 1 (text/plain, inline)]
On 09/18/2011 11:47 PM, Bill Allombert wrote:
> 
> Can you check with the debugger whether it is not a different instance of the same
> issue ? The function pari_init_parser has a similar issue.
> 
> Cheers,
> Bill.

gdb backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x001e5e8e in pari_realloc (size=960, pointer=<optimized out>) at ../src/headers/pariinl.h:842
842	  if (!tmp) pari_err(memer);
(gdb) bt
#0  0x001e5e8e in pari_realloc (size=960, pointer=<optimized out>) at ../src/headers/pariinl.h:842
#1  stack_alloc (nb=40, s=<optimized out>) at ../src/headers/pariinl.h:580
#2  pari_init_parser () at ../src/language/parsec.h:44
#3  0x001d61b4 in pari_init_blocks () at ../src/language/init.c:126
#4  pari_thread_init () at ../src/language/init.c:682
#5  pari_init_opts (parisize=<optimized out>, maxprime=<optimized out>, init_opts=<optimized out>)
    at ../src/language/init.c:750
#6  0x0002b602 in main (argc=1, argv=0x408003ac) at ../src/gp/gp.c:1984

(gdb) frame 2
(gdb) p s_node
$4 = {
  offset = 61380, 
  n = 40, 
  alloc = 40, 
  size = 24
}

this is actually the issue I originally had. I may have never encountered
the issue you fixed with the patch.
Can this function be fixed in the same way?

[signature.asc (application/pgp-signature, attachment)]

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


Acknowledgement sent to Julian Taylor <jtaylor.debian@googlemail.com>:
Extra info received and forwarded to list. Copy sent to Karim.Belabas@math.u-bordeaux.fr. (full text, mbox, link).


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

From: Julian Taylor <jtaylor.debian@googlemail.com>
To: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
Cc: 1237@pari.math.u-bordeaux.fr
Subject: Re: Bug#1237: undefined behaviour in pari_init_parser
Date: Mon, 19 Sep 2011 23:23:59 +0200
[Message part 1 (text/plain, inline)]
On 09/18/2011 11:47 PM, Bill Allombert wrote:
>>
>> unfortunately it still fails with the same issue in my qemu armel chroot
>> on ubuntu oneiric which has pretty much the same gcc version as debian
>> (4.6-9ubuntu3).
>> I don't understand why.
> 
> Can you check with the debugger whether it is not a different instance of the same
> issue ? The function pari_init_parser has a similar issue.
> 
> Cheers,
> Bill.

doing the same thing for pari_init_parser does fix the problem in my
armel emulation but one must mess with the pari_tree variable which
probably breaks api.
Maybe some header restructuring + a macro can retain it.
See attached patch which should not break api but it does break abi and
is really ugly :/
[debian-changes-2.5.0-2 (text/plain, attachment)]
[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-submit-list@pari.math.u-bordeaux.fr, Karim.Belabas@math.u-bordeaux.fr:
Bug#1237; Package pari. (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 #50 received at 1237@pari.math.u-bordeaux.fr (full text, mbox, reply):

From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
To: Julian Taylor <jtaylor.debian@googlemail.com>, 1237@pari.math.u-bordeaux.fr
Subject: Re: Bug#1237: undefined behaviour in pari_init_parser
Date: Wed, 21 Sep 2011 00:01:31 +0200
On Mon, Sep 19, 2011 at 11:23:59PM +0200, Julian Taylor wrote:
> On 09/18/2011 11:47 PM, Bill Allombert wrote:
> >>
> >> unfortunately it still fails with the same issue in my qemu armel chroot
> >> on ubuntu oneiric which has pretty much the same gcc version as debian
> >> (4.6-9ubuntu3).
> >> I don't understand why.
> > 
> > Can you check with the debugger whether it is not a different instance of the same
> > issue ? The function pari_init_parser has a similar issue.
> > 
> > Cheers,
> > Bill.
> 
> doing the same thing for pari_init_parser does fix the problem in my
> armel emulation but one must mess with the pari_tree variable which
> probably breaks api.
> Maybe some header restructuring + a macro can retain it.
> See attached patch which should not break api but it does break abi and
> is really ugly :/

Yes, this breaks the ABI. What you can do instead is leverage the fact that
s_node is static, so only this file can change pari_tree.
So you can create a 

static THREAD struct
{
  node * n;
  pari_stack s;
} tree;

and set pari_tree = tree.n before calling optimizenode() in pari_compile_str.

But probably a simpler and more robust fix would be to stop inlining stack_init
by moving it to a regular C file that preferably do not use it.

Cheers,
Bill.



Information forwarded to bug-submit-list@pari.math.u-bordeaux.fr, Karim.Belabas@math.u-bordeaux.fr:
Bug#1237; Package pari. (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 #55 received at 1237@pari.math.u-bordeaux.fr (full text, mbox, reply):

From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
To: Julian Taylor <jtaylor.debian@googlemail.com>
Cc: 1237@pari.math.u-bordeaux.fr
Subject: Re: Bug#1237: undefined behaviour in pari_init_parser
Date: Thu, 26 Jan 2012 17:25:08 +0100
On Tue, Sep 13, 2011 at 04:41:51PM +0200, Bill Allombert wrote:
> On Fri, Sep 02, 2011 at 06:57:38PM +0200, Bill Allombert wrote:
> > On Thu, Sep 01, 2011 at 11:00:43PM +0200, Julian Taylor wrote:
> > 
> > Well, you can try the attached patch which work around the compiler issue without
> > breaking the ABI (tested on sparc).
> 
> Hello Julian, 
> I have uploaded a new Debian package that includes this patch and it was built correctly
> on all platform, as you can see 
> <https://buildd.debian.org/status/package.php?p=pari>
> this includes armel and sparc. 
> Do you still have issues on armel ?
> 
> A technical note: it is possible that stack_init is not standard compliant, but it
> should be possible to rewrite it in a standard compliant according to
> <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49330#c8>
> However gcc-4.6 bug PR49330 is still open so PARI would still be miscompiled.

Hello Julian,

Sorry for the long delay,

I just fixed stack_base to be standard compliant. It seems actually improve things
with the version of gcc I tried (Debian 4.6.2-12). It did not with older versions.

This is is revision c3f6b58983. This is backported in PARI 2.5.1 in rev ee8e36931.
PARI 2.5.1 will be released soon.
Please check if that also fix things for you.

Thanks for your report,
Bill.



Information forwarded to bug-submit-list@pari.math.u-bordeaux.fr, Karim.Belabas@math.u-bordeaux.fr:
Bug#1237; Package pari. (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 #60 received at 1237@pari.math.u-bordeaux.fr (full text, mbox, reply):

From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
To: Julian Taylor <jtaylor.debian@googlemail.com>
Cc: 1237@pari.math.u-bordeaux.fr
Subject: Re: Bug#1237: undefined behaviour in pari_init_parser
Date: Sat, 28 Jan 2012 21:11:23 +0100
On Thu, Jan 26, 2012 at 05:25:08PM +0100, Bill Allombert wrote:
> On Tue, Sep 13, 2011 at 04:41:51PM +0200, Bill Allombert wrote:
> > On Fri, Sep 02, 2011 at 06:57:38PM +0200, Bill Allombert wrote:
> > > On Thu, Sep 01, 2011 at 11:00:43PM +0200, Julian Taylor wrote:
> > > 
> > > Well, you can try the attached patch which work around the compiler issue without
> > > breaking the ABI (tested on sparc).
> > 
> > Hello Julian, 
> > I have uploaded a new Debian package that includes this patch and it was built correctly
> > on all platform, as you can see 
> > <https://buildd.debian.org/status/package.php?p=pari>
> > this includes armel and sparc. 
> > Do you still have issues on armel ?
> > 
> > A technical note: it is possible that stack_init is not standard compliant, but it
> > should be possible to rewrite it in a standard compliant according to
> > <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49330#c8>
> > However gcc-4.6 bug PR49330 is still open so PARI would still be miscompiled.
> 
> Hello Julian,
> 
> Sorry for the long delay,
> 
> I just fixed stack_base to be standard compliant. It seems actually improve things
> with the version of gcc I tried (Debian 4.6.2-12). It did not with older versions.
> 
> This is is revision c3f6b58983. This is backported in PARI 2.5.1 in rev ee8e36931.
> PARI 2.5.1 will be released soon.
> Please check if that also fix things for you.

And now that the code is standard compliant, on sparc-linux, gcc 4.6.2 miscompiles it
by hitting PR49330 while it compiles correctly the non compliant code. Go figure...

Cheers,
Bill.



Reply sent to Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>:
You have taken responsibility. (full text, mbox, link).


Notification sent to Julian Taylor <jtaylor.debian@googlemail.com>:
Bug acknowledged by developer. (full text, mbox, link).


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

From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
To: Julian Taylor <jtaylor.debian@googlemail.com>
Cc: 1237-done@pari.math.u-bordeaux.fr
Subject: Re: Bug#1237: undefined behaviour in pari_init_parser
Date: Tue, 7 Feb 2012 00:14:11 +0100
On Thu, Jan 26, 2012 at 05:25:08PM +0100, Bill Allombert wrote:
> On Tue, Sep 13, 2011 at 04:41:51PM +0200, Bill Allombert wrote:
> > On Fri, Sep 02, 2011 at 06:57:38PM +0200, Bill Allombert wrote:
> > > On Thu, Sep 01, 2011 at 11:00:43PM +0200, Julian Taylor wrote:
> > > 
> > > Well, you can try the attached patch which work around the compiler issue without
> > > breaking the ABI (tested on sparc).
> > 
> > Hello Julian, 
> > I have uploaded a new Debian package that includes this patch and it was built correctly
> > on all platform, as you can see 
> > <https://buildd.debian.org/status/package.php?p=pari>
> > this includes armel and sparc. 
> > Do you still have issues on armel ?
> > 
> > A technical note: it is possible that stack_init is not standard compliant, but it
> > should be possible to rewrite it in a standard compliant according to
> > <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49330#c8>
> > However gcc-4.6 bug PR49330 is still open so PARI would still be miscompiled.
> 
> Hello Julian,
> 
> Sorry for the long delay,
> 
> I just fixed stack_base to be standard compliant. It seems actually improve things
> with the version of gcc I tried (Debian 4.6.2-12). It did not with older versions.
> 
> This is is revision c3f6b58983. This is backported in PARI 2.5.1 in rev ee8e36931.
> PARI 2.5.1 will be released soon.

I have just released PARI 2.5.1, so I close this report.
Cheers,
Bill.



Send a report that this bug log contains spam.


Bill Allombert <allomber@math.u-bordeaux.fr>. Last modified: Thu Mar 28 19:58:38 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.