[Nasm-bugs] [Bug 3392734] New: Buffered warnings in warn_list (like case 0340: "forward reference in RESx ") never actually printed (if no later fatal error)

noreply-nasm at dev.nasm.us noreply-nasm at dev.nasm.us
Sun Jan 10 23:48:58 PST 2021


https://bugzilla.nasm.us/show_bug.cgi?id=3392734

            Bug ID: 3392734
           Summary: Buffered warnings in warn_list (like case 0340:
                    "forward reference in RESx ") never actually printed
                    (if no later fatal error)
           Product: NASM
           Version: 2.16 (development)
          Hardware: All
                OS: All
            Status: OPEN
          Severity: normal
          Priority: Medium
         Component: Assembler
          Assignee: nobody at nasm.us
          Reporter: pcordes at gmail.com
                CC: chang.seok.bae at intel.com, gorcunov at gmail.com,
                    hpa at zytor.com, nasm-bugs at nasm.us
     Obtained from: From OS distribution

NASM 2.13 introduced a warning for
section .bss
resb  sz
sz: equ 8

https://godbolt.org/z/qW5qxE - with NASM 2.14.02 this warns 
./example.asm:2: warning: forward reference in RESx can have unpredictable
results [-w+other]
Tested with default -fbin and with -felf32

But nothing is printed with NASM 2.15.05 or current git master.  I even used
-w+all -w+other but still nothing.

NASM 2.15 and git master still have the code for that warning, which does
actually execute (confirmed with GDB for a breakpoint on the 
   nasm_warn(WARN_OTHER, "forward reference in RESx " ...
line 1502 in the case 0340: block in calcsize in asm/assemble.c
https://github.com/netwide-assembler/nasm/blob/79ac0d686dbf99758c9589fc4db6be4a2c5476e4/asm/assemble.c#L1502

Single-stepping into it, we reach this in asm/nasm.c in nasm_issue_error, where
the if is taken because it's just a warning.

2156    if (warn_list && true_type < ERR_NONFATAL) {
2157        /*
2158        * Buffer up warnings until we either get an error
2159        * or we are on the code-generation pass.
2160        */
2161        strlist_printf(warn_list, "%s%s%s%s%s%s%s",
2162                       file, linestr, errfmt->beforemsg,
2163                       pfx, et->msg, here, warnsuf);                        

I don't know what later code is *supposed* to print the warn_list, but
apparently that's not happening unless there actually *is* a fatal error so the
else side of this if is taken.  With this input:

section .bss
resb  sz
sz: equ 8

    db 'xy

./nasm /tmp/foo.asm  (built from git source) outputs:

/tmp/foo.asm:2: warning: forward reference in RESx can have unpredictable
results [-w+other]
/tmp/foo.asm:5: warning: unterminated string [-w+other]
/tmp/foo.asm:5: error: expression syntax error

So this detective work seems to confirm that NASM still thinks it should be
warning about that, not that NASM 2.15 made it safe and removed the error
message intentionally.


The warning is definitely getting added to warn_list, but absent a fatal error
nothing apparently gets around to printing it.  I don't know enough NASM
internals to know where to look for something that *should* be happening but
isn't.  I only found this part with grep and single-stepping from a breakpoint.
I guess there's a strlist_write somewhere that's not running, or a premature
freeing of the list before that happens.

I built NASM on x86-64 Arch GNU/Linux, with gcc (GCC) 10.2.0.
The distro build of NASM I tested is NASM version 2.15.05 compiled on Sep 24
2020
(also with Arch Linux's GCC10)

-- 
You are receiving this mail because:
You are watching all bug changes.
You are on the CC list for the bug.


More information about the Nasm-bugs mailing list