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

Reply or subscribe to this bug.

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


Report forwarded to [email protected], Anibal Monsalve Salazar <[email protected]>:
Bug#903153; Package nasm. (Sat, 07 Jul 2018 06:27:04 GMT) (full text, mbox, link).


Acknowledgement sent to Petr Vandrovec <[email protected]>:
New Bug report received and forwarded. Copy sent to Anibal Monsalve Salazar <[email protected]>. (Sat, 07 Jul 2018 06:27:04 GMT) (full text, mbox, link).


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

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
Date: Fri, 6 Jul 2018 23:08:12 -0700
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



Information forwarded to [email protected], Anibal Monsalve Salazar <[email protected]>:
Bug#903153; Package nasm. (Tue, 12 Feb 2019 09:54:02 GMT) (full text, mbox, link).


Acknowledgement sent to Jordan Justen <[email protected]>:
Extra info received and forwarded to list. Copy sent to Anibal Monsalve Salazar <[email protected]>. (Tue, 12 Feb 2019 09:54:02 GMT) (full text, mbox, link).


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

From: Jordan Justen <[email protected]>
To: [email protected]
Subject: RE: nasm does not handle rdf2 output correctly due to incorrect use of pure_func
Date: Tue, 12 Feb 2019 01:41:25 -0800
Hi. Does the 2.14-1 release fix this? I see that upstream included at
patch exactly like yours:

commit 9f45a77f46829e666b35530939b9237cf978d4dc
Author: Cyrill Gorcunov <[email protected]>
Date:   Sat Feb 10 00:40:46 2018 +0300

    nasmlib: Drop pure_func attrib from seg_alloc

This patch should have been included is 2.14-1.

Thanks,

-Jordan



Information forwarded to [email protected], Anibal Monsalve Salazar <[email protected]>:
Bug#903153; Package nasm. (Sun, 17 Nov 2019 19:54:04 GMT) (full text, mbox, link).


Acknowledgement sent to Παναγιώτης Μπίκος <[email protected]>:
Extra info received and forwarded to list. Copy sent to Anibal Monsalve Salazar <[email protected]>. (Sun, 17 Nov 2019 19:54:04 GMT) (full text, mbox, link).


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

From: Παναγιώτης Μπίκος <[email protected]>
To: "[email protected]" <[email protected]>
Subject: Re: RE: nasm does not handle rdf2 output correctly due to incorrect use of pure_func
Date: Sun, 17 Nov 2019 19:50:23 +0000
Issue persists in nasm 2.14-1 (Debian 10.2 Stable)


pbikos@dev:/home/large/code/osdev$ cat main.asm

section .text

pbikos@dev:/home/large/code/osdev$ nasm -f rdf main.asm
main.asm:panic: rdf segment numbers not allocated as expected (2,4,6)
pbikos@dev:/home/large/code/osdev$ nasm -v
NASM version 2.14



Send a report that this bug log contains spam.


Debian bug tracking system administrator <[email protected]>. Last modified: Tue May 13 13:20:50 2025; Machine Name: buxtehude

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.