<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 --- - SetErrorStringWithVarArg needs to use vscprintf on Windows"
href="http://llvm.org/bugs/show_bug.cgi?id=22536">22536</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>SetErrorStringWithVarArg needs to use vscprintf on Windows
</td>
</tr>
<tr>
<th>Product</th>
<td>lldb
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>amccarth@google.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>zturner@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>lldb-dev@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>In Error::SetErrorStringWithVarArg(), lldb calls vsnprintf. To be standards
conformant, the function must return "The number of characters that would have
been written if n had been sufficiently large, not counting the terminating
null character." (<a href="http://www.cplusplus.com/reference/cstdio/vsnprintf/">http://www.cplusplus.com/reference/cstdio/vsnprintf/</a>). On
Windows, apparently, "if the number of characters to write is greater than
count, these functions return -1 indicating that output has been truncated."
(<a href="https://msdn.microsoft.com/en-us/library/1kt27hek.aspx">https://msdn.microsoft.com/en-us/library/1kt27hek.aspx</a>).
This sometimes triggers a segfault in this function (Thanks to ki9a for
finding this).
It seems that on Windows we need to call _vscprintf
(<a href="https://msdn.microsoft.com/en-us/library/w05tbk72.aspx">https://msdn.microsoft.com/en-us/library/w05tbk72.aspx</a>) in order to determine
the correct buffer size before calling vsnprintf.
Not sure how to reproduce this in live code, but a test that calls
SBError::SetExpressionErrorWithFormat() should be able to for this code path,
and would also be a good test to have anyway.</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>