PARI/GP Bug report logs -
#1237
undefined behaviour in pari_init_parser
Full log
🔗
View this message in rfc822 format
Your message dated Tue, 7 Feb 2012 00:14:11 +0100
with message-id <20120206231411.GD7664@yellowpig>
and subject line Bug#1237: undefined behaviour in pari_init_parser
has caused the attached Bug report to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere. Please contact me immediately.)
Bill Allombert
(administrator, PARI/GP bugs database)
--------------------------------------
Received: (at submit) by pari.math.u-bordeaux.fr; 31 Aug 2011 15:27:09 +0000
From jtaylor.debian@googlemail.com Wed Aug 31 17:27:09 2011
Received: from mail-ew0-f45.google.com ([209.85.215.45])
by pari.math.u-bordeaux1.fr with esmtp (Exim 4.69)
(envelope-from <jtaylor.debian@googlemail.com>)
id 1Qymh3-0006Nn-R6
for submit@pari.math.u-bordeaux.fr; Wed, 31 Aug 2011 17:27:09 +0200
Received: by ewy24 with SMTP id 24so690526ewy.32
for <submit@pari.math.u-bordeaux.fr>; Wed, 31 Aug 2011 08:27:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=googlemail.com; s=gamma;
h=message-id:date:from:user-agent:mime-version:to:cc:subject
:content-type:content-transfer-encoding;
bh=HBoAKHvxYuq24tMj8HZC5MGD9tT6wsSK9EaGSmv6jbY=;
b=rW8SAAz9QLwhzPjnhnNQDV+96lErhRQg8wwCzaGMzM88lBNwHo5mrm3Zu+LmL4HIY4
m40FvJ2AixVtymYwMJsypAkieYFYzRhOulnwmlaVRCizqfqp6x/3CnXwGMmNqIED8PSP
GRidPLLH3bmDNZxADd6MN5kNrIwU9toanHcZM=
Received: by 10.213.113.16 with SMTP id y16mr358039ebp.32.1314804424326;
Wed, 31 Aug 2011 08:27:04 -0700 (PDT)
Received: from [192.168.0.11] (p5498C2E5.dip.t-dialin.net [84.152.194.229])
by mx.google.com with ESMTPS id b12sm3723738een.30.2011.08.31.08.27.02
(version=SSLv3 cipher=OTHER);
Wed, 31 Aug 2011 08:27:03 -0700 (PDT)
Message-ID: <4E5E52C5.4050702@googlemail.com>
Date: Wed, 31 Aug 2011 17:27:01 +0200
From: Julian Taylor <jtaylor.debian@googlemail.com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0) Gecko/20110828 Thunderbird/7.0
MIME-Version: 1.0
To: submit@pari.math.u-bordeaux.fr
CC: ballombe@debian.org
Subject: undefined behaviour in pari_init_parser
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
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
---------------------------------------
Received: (at 1237-done) by pari.math.u-bordeaux.fr; 6 Feb 2012 23:14:18 +0000
From Bill.Allombert@math.u-bordeaux1.fr Tue Feb 07 00:14:18 2012
Received: from smtp1-g21.free.fr ([212.27.42.1])
by pari.math.u-bordeaux1.fr with esmtp (Exim 4.72)
(envelope-from <Bill.Allombert@math.u-bordeaux1.fr>)
id 1RuXlK-0001Ok-GR
for 1237-done@pari.math.u-bordeaux.fr; Tue, 07 Feb 2012 00:14:18 +0100
Received: from yellowpig (unknown [IPv6:2a01:e35:2f45:9a0:223:14ff:fe3e:4490])
by smtp1-g21.free.fr (Postfix) with ESMTP id 0CFF89400E1;
Tue, 7 Feb 2012 00:14:12 +0100 (CET)
Received: from bill by yellowpig with local (Exim 4.72)
(envelope-from <Bill.Allombert@math.u-bordeaux1.fr>)
id 1RuXlD-0005WQ-NK; Tue, 07 Feb 2012 00:14:11 +0100
Date: Tue, 7 Feb 2012 00:14:11 +0100
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
Message-ID: <20120206231411.GD7664@yellowpig>
References: <4E5E52C5.4050702@googlemail.com>
<20110901202245.GH17070@yellowpig>
<4E5FF27B.5080600@googlemail.com>
<20110902165738.GM17070@yellowpig>
<20110913144151.GE6199@yellowpig>
<20120126162508.GA18262@yellowpig>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20120126162508.GA18262@yellowpig>
User-Agent: Mutt/1.5.20 (2009-06-14)
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:
Sat Aug 26 17:15:16 2023;
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.