[lldb-dev] [Bug 22536] New: SetErrorStringWithVarArg needs to use vscprintf on Windows

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Feb 10 14:25:06 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22536

            Bug ID: 22536
           Summary: SetErrorStringWithVarArg needs to use vscprintf on
                    Windows
           Product: lldb
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: amccarth at google.com
          Reporter: zturner at google.com
                CC: lldb-dev at cs.uiuc.edu
    Classification: Unclassified

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."  (http://www.cplusplus.com/reference/cstdio/vsnprintf/).  On
Windows, apparently, "if the number of characters to write is greater than
count, these functions return -1 indicating that output has been truncated."
(https://msdn.microsoft.com/en-us/library/1kt27hek.aspx).

This sometimes triggers a segfault in this function  (Thanks to ki9a for
finding this).

It seems that on Windows we need to call _vscprintf
(https://msdn.microsoft.com/en-us/library/w05tbk72.aspx) 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.

-- 
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/lldb-dev/attachments/20150210/4955c3fc/attachment.html>


More information about the lldb-dev mailing list