Track histories with shared_ptr

Prior to this change, histories were immortal and allocated with either
unique_ptr or just leaked via new. But this can result in races in the
path detection test, as the destructor races with the pointer-captured
history. Switch to using shared_ptr.
This commit is contained in:
ridiculousfish
2021-01-09 16:22:32 -08:00
parent e062a07a97
commit e8c9da100c
10 changed files with 100 additions and 85 deletions

View File

@@ -687,9 +687,9 @@ maybe_t<env_var_t> env_scoped_impl_t::try_get_computed(const wcstring &key) cons
return none();
}
history_t *history = reader_get_history();
std::shared_ptr<history_t> history = reader_get_history();
if (!history) {
history = &history_t::history_with_name(history_session_id(*this));
history = history_t::with_name(history_session_id(*this));
}
wcstring_list_t result;
if (history) history->get_history(result);