Reviewers: Vitaly Repeshko,
Message:
strncpy_s() actually crashes (asserts in dbg) if it is told to copy more
characters then the destination buffer allows.
The thread name is limited at 15chars + \0. So in some cases we were
exceeding
that ("TerminationThread"). Need to use _TRUNCATE option with strncpy_s().
TBR=vitalyr
Description:
Fix Win32 bots - they crash/timeout on too long thread name.
Please review this at http://codereview.chromium.org/6676076/
SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/
Affected files:
M src/platform-win32.cc
M src/win32-headers.h
Index: src/platform-win32.cc
===================================================================
--- src/platform-win32.cc (revision 7294)
+++ src/platform-win32.cc (working copy)
@@ -754,9 +754,13 @@
void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
+ // Use _TRUNCATE or strncpy_s asserts (by design) if buffer is too small.
+ size_t buffer_size = static_cast<size_t>(dest.length());
+ if (n + 1 > buffer_size) // count for trailing '\0'
+ n = _TRUNCATE;
int result = strncpy_s(dest.start(), dest.length(), src, n);
USE(result);
- ASSERT(result == 0);
+ ASSERT(result == 0 || (n == _TRUNCATE && result == STRUNCATE));
}
Index: src/win32-headers.h
===================================================================
--- src/win32-headers.h (revision 7294)
+++ src/win32-headers.h (working copy)
@@ -66,6 +66,7 @@
#endif // __MINGW32__
#ifndef __MINGW32__
#include <dbghelp.h> // For SymLoadModule64 and al.
+#include <errno.h> // For STRUNCATE
#endif // __MINGW32__
#include <limits.h> // For INT_MAX and al.
#include <tlhelp32.h> // For Module32First and al.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev