Deliberately leak our cached tag.
HWASan was unhappy that some binder code was calling `__android_log_print`
and accessing `last_tag` during exit, after liblog's destructors had
run. The old code didn't have this issue because it just leaked its
`char*`, so that seems like an easy fix.
Yet another case where we should have had -Wexit-time-destructors...
I'll come back for that rather than try to fix everything at once (since
this isn't the only one).
Bug: http://b/181830525
Test: treehugger
Change-Id: I0e5a57dc0b6479e757dd10dce7bb8ea74bd577c1
diff --git a/liblog/properties.cpp b/liblog/properties.cpp
index bfcbef8..bd5f5e7 100644
--- a/liblog/properties.cpp
+++ b/liblog/properties.cpp
@@ -111,7 +111,7 @@
* Where the missing tag matches all tags and becomes the
* system global default. We do not support ro.log.tag* .
*/
- static std::string last_tag;
+ static std::string* last_tag = new std::string;
static uint32_t global_serial;
uint32_t current_global_serial;
static cache_char tag_cache[2];
@@ -149,13 +149,13 @@
bool local_change_detected = change_detected;
if (locked) {
// compare() rather than == because tag isn't guaranteed 0-terminated.
- if (last_tag.compare(0, last_tag.size(), tag, tag_len) != 0) {
+ if (last_tag->compare(0, last_tag->size(), tag, tag_len) != 0) {
// Invalidate log.tag.<tag> cache.
for (size_t i = 0; i < arraysize(tag_cache); ++i) {
tag_cache[i].cache.pinfo = NULL;
tag_cache[i].c = '\0';
}
- last_tag.assign(tag, tag_len);
+ last_tag->assign(tag, tag_len);
local_change_detected = true;
}
}