[scudo][standalone] Fix for releaseToOS prior to init
authorKostya Kortchinsky <kostyak@google.com>
Thu, 21 Nov 2019 18:57:49 +0000 (10:57 -0800)
committerKostya Kortchinsky <kostyak@google.com>
Mon, 25 Nov 2019 16:38:45 +0000 (08:38 -0800)
commit15664fe2c48be242b4b38422466246e9592b6670
tree26e2a6b7efba375c86d91f7e8b8e69d64489240a
parentbec37c3fc766a7b97f8c52c181c325fd47b75259
[scudo][standalone] Fix for releaseToOS prior to init

Summary:
cferris@ found an issue where calling `releaseToOS` prior to any other
heap operation would lead to a crash, due to the allocator not being
properly initialized (it was discovered via `mallopt`).

The fix is to call `initThreadMaybe` prior to calling `releaseToOS` for
the Primary.

Add a test that crashes prior to fix.

Reviewers: hctim, cferris, pcc, eugenis

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D70552
compiler-rt/lib/scudo/standalone/combined.h
compiler-rt/lib/scudo/standalone/tests/combined_test.cpp