Update locking in dbghelp_syminit_manager
This commit is contained in:
parent
c896d70f79
commit
8d6326da07
@ -4,7 +4,6 @@
|
|||||||
#include "../utils/common.hpp"
|
#include "../utils/common.hpp"
|
||||||
#include "../utils/utils.hpp"
|
#include "../utils/utils.hpp"
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@ -14,7 +13,6 @@ namespace cpptrace {
|
|||||||
namespace detail {
|
namespace detail {
|
||||||
struct dbghelp_syminit_manager {
|
struct dbghelp_syminit_manager {
|
||||||
std::unordered_set<HANDLE> set;
|
std::unordered_set<HANDLE> set;
|
||||||
std::mutex mutex;
|
|
||||||
|
|
||||||
~dbghelp_syminit_manager() {
|
~dbghelp_syminit_manager() {
|
||||||
for(auto handle : set) {
|
for(auto handle : set) {
|
||||||
@ -26,7 +24,6 @@ namespace detail {
|
|||||||
|
|
||||||
void init(HANDLE proc) {
|
void init(HANDLE proc) {
|
||||||
if(set.count(proc) == 0) {
|
if(set.count(proc) == 0) {
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
|
||||||
if(!SymInitialize(proc, NULL, TRUE)) {
|
if(!SymInitialize(proc, NULL, TRUE)) {
|
||||||
throw std::logic_error(stringf("SymInitialize failed %llu", to_ull(GetLastError())));
|
throw std::logic_error(stringf("SymInitialize failed %llu", to_ull(GetLastError())));
|
||||||
}
|
}
|
||||||
@ -35,6 +32,7 @@ namespace detail {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Thread-safety: Must only be called from symbols_with_dbghelp while the dbghelp_lock lock is held
|
||||||
inline dbghelp_syminit_manager& get_syminit_manager() {
|
inline dbghelp_syminit_manager& get_syminit_manager() {
|
||||||
static dbghelp_syminit_manager syminit_manager;
|
static dbghelp_syminit_manager syminit_manager;
|
||||||
return syminit_manager;
|
return syminit_manager;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user