[sanitizer] Make destructors protected

This commit is contained in:
Vitaly Buka 2020-11-02 16:42:20 -08:00
parent b0f1d7d562
commit 8b37a4e6ca
10 changed files with 14 additions and 9 deletions

View File

@ -35,7 +35,7 @@ class AsanThread;
// These objects are created for every thread and are never deleted,
// so we can find them by tid even if the thread is long dead.
class AsanThreadContext : public ThreadContextBase {
class AsanThreadContext final : public ThreadContextBase {
public:
explicit AsanThreadContext(int tid)
: ThreadContextBase(tid), announced(false),

View File

@ -27,7 +27,7 @@ struct DTLS;
namespace __lsan {
class ThreadContext : public ThreadContextLsanBase {
class ThreadContext final : public ThreadContextLsanBase {
public:
explicit ThreadContext(int tid);
void OnStarted(void *arg) override;

View File

@ -32,6 +32,7 @@ class ThreadContextLsanBase : public ThreadContextBase {
void *onstarted_arg);
protected:
~ThreadContextLsanBase(){};
uptr stack_begin_ = 0;
uptr stack_end_ = 0;
uptr cache_begin_ = 0;

View File

@ -34,7 +34,7 @@ class MemprofThread;
// These objects are created for every thread and are never deleted,
// so we can find them by tid even if the thread is long dead.
struct MemprofThreadContext : public ThreadContextBase {
struct MemprofThreadContext final : public ThreadContextBase {
explicit MemprofThreadContext(int tid)
: ThreadContextBase(tid), announced(false),
destructor_iterations(GetPthreadDestructorIterations()), stack_id(0),

View File

@ -32,7 +32,7 @@ struct DDLogicalThread {
bool report_pending;
};
struct DD : public DDetector {
struct DD final : public DDetector {
SpinMutex mtx;
DeadlockDetector<DDBV> dd;
DDFlags flags;

View File

@ -80,7 +80,7 @@ struct Mutex {
Link link[kMaxLink];
};
struct DD : public DDetector {
struct DD final : public DDetector {
explicit DD(const DDFlags *flags);
DDPhysicalThread* CreatePhysicalThread();

View File

@ -85,6 +85,9 @@ struct DDetector {
virtual void MutexDestroy(DDCallback *cb, DDMutex *m) {}
virtual DDReport *GetReport(DDCallback *cb) { return nullptr; }
protected:
~DDetector(){};
};
} // namespace __sanitizer

View File

@ -39,8 +39,6 @@ enum class ThreadType {
class ThreadContextBase {
public:
explicit ThreadContextBase(u32 tid);
~ThreadContextBase(); // Should never be called.
const u32 tid; // Thread ID. Main thread should have tid = 0.
u64 unique_id; // Unique thread ID.
u32 reuse_count; // Number of times this tid was reused.
@ -80,6 +78,9 @@ class ThreadContextBase {
virtual void OnCreated(void *arg) {}
virtual void OnReset() {}
virtual void OnDetached(void *arg) {}
protected:
~ThreadContextBase();
};
typedef ThreadContextBase* (*ThreadContextFactory)(u32 tid);

View File

@ -162,7 +162,7 @@ struct RunThreadArgs {
uptr shard; // started from 1.
};
class TestThreadContext : public ThreadContextBase {
class TestThreadContext final : public ThreadContextBase {
public:
explicit TestThreadContext(int tid) : ThreadContextBase(tid) {}
void OnJoined(void *arg) {

View File

@ -477,7 +477,7 @@ inline void cur_thread_finalize() { }
#endif // SANITIZER_MAC || SANITIZER_ANDROID
#endif // SANITIZER_GO
class ThreadContext : public ThreadContextBase {
class ThreadContext final : public ThreadContextBase {
public:
explicit ThreadContext(int tid);
~ThreadContext();