[Nasm-bugs] [Bug 3392378] New: Preprocessor include search paths broken with macros

no-reply at bugzilla-nasm.gorcunov.org no-reply at bugzilla-nasm.gorcunov.org
Thu Dec 15 04:09:54 PST 2016


            Bug ID: 3392378
           Summary: Preprocessor include search paths broken with macros
           Product: NASM
           Version: unspecified
          Hardware: All
                OS: All
            Status: OPEN
          Severity: normal
          Priority: Medium
         Component: Assembler
          Assignee: nobody at nasm.us
          Reporter: ryan.prichard at gmail.com
                CC: gorcunov at gmail.com, hpa at zytor.com, nasm-bugs at nasm.us

Test case:

mkdir A

cat > A/foo.asm << EOF
%include "bar.asm"
baz 1

cat > A/bar.asm << EOF
%macro baz 1

nasm A/foo.asm -IA/

nasm should exit successfully and quietly, but the nasm on the master branch
instead fails:

A/foo.asm:2: warning: label `baz' defined on pass two
A/foo.asm:2: error: parser: instruction expected

The version shipped with Ubuntu 16.04, NASM version 2.11.08, works.

I bisected the problem, and it identified this commit:

Author: H. Peter Anvin <hpa at zytor.com>  2016-09-25 19:08:05
Committer: H. Peter Anvin <hpa at zytor.com>  2016-09-25 19:08:05

    Add a hash for pathname searches, instead of searching very pass

    We have been doing a pathname search every time we encounter a file,
    which means every file in every pass.  Instead, put the pathnames
    found in a hash table.

    Signed-off-by: H. Peter Anvin <hpa at zytor.com>

The problem seems to be with these 2 lines in inc_fopen:

    if (!fp && omode != INC_PROBE)
        fp = nasm_open_read(file, fmode);

If nasm is opening a file, and it was previously found, then we'll reach the
above code with `fp==NULL`, `file` referring to the searched-for name, and
`path` referring to the found file.  I'm guessing nasm should have passed
`path` instead of `file` to `nasm_open_read`.

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

More information about the Nasm-bugs mailing list