<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - On windows %INCLUDE% ending in \ leads to clang hanging when trying to kick of new process"
href="http://llvm.org/bugs/show_bug.cgi?id=15802">15802</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>On windows %INCLUDE% ending in \ leads to clang hanging when trying to kick of new process
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>van_kessel@freenet.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=10389" name="attach_10389" title="possible patch">attachment 10389</a> <a href="attachment.cgi?id=10389&action=edit" title="possible patch">[details]</a></span>
possible patch
On Windows, invoking "clang test.c" makes clang hang during startup if
%INCLUDE% ends in a \ and presumably some similar conditions as well.
The problem has been described by user qble on
<a href="http://stackoverflow.com/questions/15992645/clang-compiler-hangs-on-windows">http://stackoverflow.com/questions/15992645/clang-compiler-hangs-on-windows</a>
When clang gets invoked with actual work, it assembles a list of arguments and
kicks of a new process. Among those arguments is the include environment
variable on windows. In case this variable contains spaces or some other (e.g.
"C:\Program Files\SomeVendor\Include\") or some other special characters, clang
adds quotation marks around this string so that it stays a single argument to
the new process. If the argument ends in an uneven number (typically one) of
backslashes though, the quotation mark becomes escaped and thus instead of a
invocation like
clang "C:\Program Files\SomeVendor\Include\\" someOtherArg
which makes
argv[1] = "C:\\Program Files\\SomeVendor\\Include\\"
argv[2] = "someOtherArg"
it becomes
clang "C:\Program Files\SomeVendor\Include\" someOtherArg
which is a unterminated
argv[1] = "C:\\Program Files\\SomeVendor\\Include\" someOtherArg ...
The problem can easily be fixed by escaping uneven trailing backslashes by just
adding another one. I have added a pach to llvm\lib\Support\Windows which fixes
the problem, I didn't feel like messing around with c-strings like the rest of
that code does. If you feel strongly about it, I could also write a patch in
keeping with the c-style code and without unnecessary copies (though I don't
think that code is remotely performance critical)</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>