diff options
author | Hans Wennborg <hans@hanshq.net> | 2013-12-19 20:32:44 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2013-12-19 20:32:44 +0000 |
commit | fabf8bfdeadfa6f95bc3f1851425b3ef5967f254 (patch) | |
tree | f9253228d7dbaba834aa4d4c2ba6709efb447b46 /llvm/lib/Support/ThreadLocal.cpp | |
parent | fb9e92b1670c2e6fd2d1588ea982c618e559d8aa (diff) | |
download | bcm5719-llvm-fabf8bfdeadfa6f95bc3f1851425b3ef5967f254.tar.gz bcm5719-llvm-fabf8bfdeadfa6f95bc3f1851425b3ef5967f254.zip |
Make sys::ThreadLocal<> zero-initialized on non-thread builds (PR18205)
According to the docs, ThreadLocal<>::get() should return NULL
if no object has been set. This patch makes that the case also for non-thread
builds and adds a very basic unit test to check it.
(This was causing PR18205 because PrettyStackTraceHead didn't get zero-
initialized and we'd crash trying to read past the end of that list. We didn't
notice this so much on Linux since we'd crash after printing all the entries,
but on Mac we print into a SmallString, and would crash before printing that.)
llvm-svn: 197718
Diffstat (limited to 'llvm/lib/Support/ThreadLocal.cpp')
-rw-r--r-- | llvm/lib/Support/ThreadLocal.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Support/ThreadLocal.cpp b/llvm/lib/Support/ThreadLocal.cpp index 0587aaec7e6..868b6ea566a 100644 --- a/llvm/lib/Support/ThreadLocal.cpp +++ b/llvm/lib/Support/ThreadLocal.cpp @@ -23,7 +23,7 @@ // Define all methods as no-ops if threading is explicitly disabled namespace llvm { using namespace sys; -ThreadLocalImpl::ThreadLocalImpl() { } +ThreadLocalImpl::ThreadLocalImpl() : data() { } ThreadLocalImpl::~ThreadLocalImpl() { } void ThreadLocalImpl::setInstance(const void* d) { typedef int SIZE_TOO_BIG[sizeof(d) <= sizeof(data) ? 1 : -1]; |