summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2018-02-13 23:23:59 +0000
committerSam McCall <sam.mccall@gmail.com>2018-02-13 23:23:59 +0000
commit6358064d02aba4c65b651364a10357ba8d74b3c1 (patch)
tree9befa9a4a6fbf6810703a43ddd0f20af2bd83438 /llvm/lib/Support/Unix
parent361b5e116981855726e64e64f9d8784f92e2f698 (diff)
downloadbcm5719-llvm-6358064d02aba4c65b651364a10357ba8d74b3c1.tar.gz
bcm5719-llvm-6358064d02aba4c65b651364a10357ba8d74b3c1.zip
Fix off-by-one in set_thread_name which causes truncation to fail on Linux
llvm-svn: 325069
Diffstat (limited to 'llvm/lib/Support/Unix')
-rw-r--r--llvm/lib/Support/Unix/Threading.inc3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc
index 7369cff8466..2337b2c76cc 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -138,8 +138,9 @@ void llvm::set_thread_name(const Twine &Name) {
// terminated, but additionally the end of a long thread name will usually
// be more unique than the beginning, since a common pattern is for similar
// threads to share a common prefix.
+ // Note that the name length includes the null terminator.
if (get_max_thread_name_length() > 0)
- NameStr = NameStr.take_back(get_max_thread_name_length());
+ NameStr = NameStr.take_back(get_max_thread_name_length() - 1);
(void)NameStr;
#if defined(__linux__)
#if (defined(__GLIBC__) && defined(_GNU_SOURCE)) || defined(__ANDROID__)
OpenPOWER on IntegriCloud