Debian Bug report logs - #903153
nasm does not handle rdf2 output correctly due to incorrect use of pure_func

version graph

Package: nasm; Maintainer for nasm is Jordan Justen <[email protected]>; Source for nasm is src:nasm (PTS, buildd, popcon).

Reported by: Petr Vandrovec <[email protected]>

Date: Sat, 7 Jul 2018 06:27:02 UTC

Severity: normal

Found in version nasm/2.13.03-1

Full log


Message #5 received at [email protected] (full text, mbox, reply):

Received: (at submit) by bugs.debian.org; 7 Jul 2018 06:23:18 +0000
From [email protected] Sat Jul 07 06:23:18 2018
X-Spam-Checker-Version: SpamAssassin 3.4.1-bugs.debian.org_2005_01_02
	(2015-04-28) on buxtehude.debian.org
X-Spam-Level: 
X-Spam-Status: No, score=-9.6 required=4.0 tests=BAYES_00,HAS_PACKAGE,
	HEADER_FROM_DIFFERENT_DOMAINS,MURPHY_DRUGS_REL8,RCVD_IN_DNSWL_MED,SPF_PASS
	autolearn=ham autolearn_force=no version=3.4.1-bugs.debian.org_2005_01_02
X-Spam-Bayes: score:0.0000 Tokens: new, 75; hammy, 97; neutral, 40; spammy, 1.
	spammytokens:0.950-+--our hammytokens:0.000-+--H*UA:2018-05-17,
	0.000-+--H*u:2018-05-17, 0.000-+--H*UA:1.10.0, 0.000-+--H*u:1.10.0,
	0.000-+--signedoffby
Return-path: <[email protected]>
Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189])
	by buxtehude.debian.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256)
	(Exim 4.89)
	(envelope-from <[email protected]>)
	id 1fbgcn-0005gt-RD
	for [email protected]; Sat, 07 Jul 2018 06:23:18 +0000
Received: from sc9-mailhost2.vmware.com (10.113.161.72) by
 EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id
 15.0.1156.6; Fri, 6 Jul 2018 23:08:04 -0700
Received: from petr-dev3.eng.vmware.com (petr-dev2.eng.vmware.com [10.20.93.186])
	by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 8F30BB07B6;
	Fri,  6 Jul 2018 23:08:12 -0700 (PDT)
Received: by petr-dev3.eng.vmware.com (Postfix, from userid 884)
	id 8890DA0252F; Fri,  6 Jul 2018 23:08:12 -0700 (PDT)
Date: Fri, 6 Jul 2018 23:08:12 -0700
From: Petr Vandrovec <[email protected]>
To: <[email protected]>
CC: <[email protected]>, <[email protected]>, <[email protected]>
Subject: nasm does not handle rdf2 output correctly due to incorrect use of
 pure_func
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
User-Agent: Mutt/1.10.0 (2018-05-17)
Received-SPF: None (EX13-EDG-OU-001.vmware.com: [email protected] does not
 designate permitted sender hosts)
X-Greylist: delayed 903 seconds by postgrey-1.36 at buxtehude; Sat, 07 Jul 2018 06:23:17 UTC
Delivered-To: [email protected]
Package: nasm
Version: 2.13.03-1

Hi,
  when I tried to switch to new nasm for one of our projects,
nasm started panicking;

nasm: panic: rdf segment numbers not allocated as expected (0,0,0)

nasm code in question calls seg_alloc 3 times:

    segtext = seg_alloc();
    segdata = seg_alloc();
    segbss = seg_alloc();
    if (segtext != 0 || segdata != 2 || segbss != 4)
        nasm_panic(0,
              "rdf segment numbers not allocated as expected (%d,%d,%d)",
              segtext, segdata, segbss);

and seg_alloc returns consecutive even integers, so it should never
happen that all three would be zeroes.

Except that seg_alloc() is marked as pure_func, and so new gcc figures
out that seg_alloc() returns constant, and so it can call it just once,
and then assign returned value to all three variables :-(

Simple fix below solves the problem.

Petr

Signed-off-by: Petr Vandrovec <[email protected]>

--- nasm-2.13.03/include/nasmlib.h	2018-02-07 13:40:15.000000000 -0800
+++ nasm-2.13.03.patched/include/nasmlib.h	2018-07-06 22:59:37.595561715 -0700
@@ -192,7 +192,7 @@
  * seg_alloc: allocate a hitherto unused segment number.
  */
 void pure_func seg_init(void);
-int32_t pure_func seg_alloc(void);
+int32_t seg_alloc(void);
 
 /*
  * many output formats will be able to make use of this: a standard



Send a report that this bug log contains spam.


Debian bug tracking system administrator <[email protected]>. Last modified: Tue May 13 17:38:53 2025; Machine Name: bembo

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU General 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.