[llvm-bugs] [Bug 44443] New: Fix printing of malformed address values not passed via stdin

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 2 07:57:09 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=44443

            Bug ID: 44443
           Summary: Fix printing of malformed address values not passed
                    via stdin
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: llvm-symbolizer
          Assignee: unassignedbugs at nondot.org
          Reporter: jh7370.2008 at my.bristol.ac.uk
                CC: llvm-bugs at lists.llvm.org

llvm-symbolizer prints the entire "address" argument for an invalid address
that it reads, before continuing as normal. For example, the first RUN command
in the lit test llvm/test/tools/llvm-symbolizer/sym.test prints the following:

C:\llvm\llvm-project\llvm\test\tools\llvm-symbolizer>c:\llvm\build\debug\bin\llvm-symbolizer.exe
"-print-address"
"-obj=C:\llvm\llvm-project\llvm\test\tools\llvm-symbolizer/Inputs/addr.exe" <
Inputs\addr.inp
some text
0x40054d
inctwo
/tmp\x.c:3:3
inc
/tmp\x.c:7:0
main
/tmp\x.c:14:0

some text2

C:\llvm\llvm-project\llvm\test\tools\llvm-symbolizer>

For reference, addr.inp is as follows:

some text
0x40054d
some text2

However, if the bad value is on the command line instead of fed via stdin, it
does not print the new line after the bad value:

C:\llvm\llvm-project\llvm\test\tools\llvm-symbolizer>c:\llvm\build\debug\bin\llvm-symbolizer.exe
"-print-address"
"-obj=C:\llvm\llvm-project\llvm\test\tools\llvm-symbolizer/Inputs/addr.exe"
"some text" 0x40054d "some text2"
some text0x40054d
inctwo
/tmp\x.c:3:3
inc
/tmp\x.c:7:0
main
/tmp\x.c:14:0

some text2
C:\llvm\llvm-project\llvm\test\tools\llvm-symbolizer>

A similar problem occurs if addr.inp is passed in as a response file, instead
of via stdin (note that in this case, the strings with spaces in need to be
quoted or they'll be treated as separate arguments and the spaces will be lost
completely!).

I suspect that the problem is not seen when read via stdin because the newline
character in the file itself is being included in the string that is printed.
This character obviously doesn't appear when the value is on the command-line
directly, and in response files, the new lines are treated as argument
separators so are likely similarly lost.

Finally, it's worth noting that sym.test wouldn't fail even if the bad values
were passed on the command-line, becuase it doesn't use CHECK-NEXT, only CHECK.

I think there are therefore several things that need doing to fix this issue:
1) Strip the new line characters that are somehow included when reading from
stdin. This should ensure that stdin bad inputs are treated the same as the
other situations.
2) Add the new line that is missing when printing bad input values.
3) Fix sym.test to use CHECK-NEXT (this could be a separate change).
4) Add more comprehensive testing for malformed input printing (i.e. from all
possible sources).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200102/fe1d4bda/attachment.html>


More information about the llvm-bugs mailing list