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.

Full log


🔗 View this message in rfc822 format

X-Loop: allomber@math.u-bordeaux.fr
Subject: Bug#1237: undefined behaviour in pari_init_parser
Reply-To: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>, 1237@pari.math.u-bordeaux.fr
Resent-From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
Resent-To: bug-submit-list@pari.math.u-bordeaux.fr
Resent-CC: Karim.Belabas@math.u-bordeaux.fr
Resent-Date: Tue, 20 Sep 2011 22:03:02 UTC
Resent-Message-ID: <handler.1237.B1237.131655609727336@pari.math.u-bordeaux.fr>
Resent-Sender: allomber@math.u-bordeaux.fr
X-PARI/GP-PR-Message: report 1237
X-PARI/GP-PR-Package: pari
X-PARI/GP-PR-Keywords: 
Received: via spool by 1237-submit@pari.math.u-bordeaux.fr id=B1237.131655609727336
          (code B ref 1237); Tue, 20 Sep 2011 22:03:02 UTC
Received: (at 1237) by pari.math.u-bordeaux.fr; 20 Sep 2011 22:01:37 +0000
Received: from smtp1-g21.free.fr ([212.27.42.1])
	by pari.math.u-bordeaux1.fr with esmtp (Exim 4.69)
	(envelope-from <Bill.Allombert@math.u-bordeaux1.fr>)
	id 1R68Nl-00076r-FG
	for 1237@pari.math.u-bordeaux.fr; Wed, 21 Sep 2011 00:01:37 +0200
Received: from yellowpig (unknown [IPv6:2a01:e35:2f45:9a0:223:14ff:fe3e:4490])
	by smtp1-g21.free.fr (Postfix) with ESMTP id 21DDA94012C;
	Wed, 21 Sep 2011 00:01:32 +0200 (CEST)
Received: from bill by yellowpig with local (Exim 4.72)
	(envelope-from <Bill.Allombert@math.u-bordeaux1.fr>)
	id 1R68Nf-0008Pd-QE; Wed, 21 Sep 2011 00:01:31 +0200
Date: Wed, 21 Sep 2011 00:01:31 +0200
From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
To: Julian Taylor <jtaylor.debian@googlemail.com>,
	1237@pari.math.u-bordeaux.fr
Message-ID: <20110920220131.GH21798@yellowpig>
References: <4E5E52C5.4050702@googlemail.com>
 <20110901202245.GH17070@yellowpig>
 <4E5FF27B.5080600@googlemail.com>
 <20110902165738.GM17070@yellowpig>
 <20110913144151.GE6199@yellowpig>
 <4E76503A.9070006@googlemail.com>
 <20110918214754.GM18359@yellowpig>
 <4E77B2EF.8080000@googlemail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4E77B2EF.8080000@googlemail.com>
User-Agent: Mutt/1.5.20 (2009-06-14)
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.



Send a report that this bug log contains spam.


Bill Allombert <allomber@math.u-bordeaux.fr>. Last modified: Sat Aug 26 17:15:14 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.