From 6f91195f403c9e50f2fa44baab6e3bfad19c44ce Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Fri, 8 Jan 2021 14:14:05 -0800 Subject: [PATCH] Stop using unique_ptr to store histories These register shutdown dtors, which cause tsan to complain. --- src/history.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/history.cpp b/src/history.cpp index 647176094..2bf4fed8e 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -1481,8 +1481,8 @@ history_item_t history_t::item_at_index(size_t idx) { return impl()->item_at_ind size_t history_t::size() { return impl()->size(); } -/// The set of all histories. -static owning_lock>> s_histories; +/// The set of all histories. These are deliberately leaked to avoid shutdown dtors. +static owning_lock> s_histories; void history_save_all() { auto histories = s_histories.acquire(); @@ -1492,13 +1492,13 @@ void history_save_all() { } history_t &history_t::history_with_name(const wcstring &name) { - // Return a history for the given name, creating it if necessary + // Return a history for the given name, creating it if necessary. // Note that histories are currently never deleted, so we can return a reference to them without - // using something like shared_ptr + // using something like shared_ptr. auto hs = s_histories.acquire(); - std::unique_ptr &hist = (*hs)[name]; + history_t *&hist = (*hs)[name]; if (!hist) { - hist = make_unique(name); + hist = new history_t(name); } return *hist; }