<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Fix printing of malformed address values not passed via stdin"
   href="https://bugs.llvm.org/show_bug.cgi?id=44443">44443</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Fix printing of malformed address values not passed via stdin
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>llvm-symbolizer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jh7370.2008@my.bristol.ac.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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).</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>