-
Notifications
You must be signed in to change notification settings - Fork 15k
Description
I'm trying to figure out if this is a me problem or a false positive.
During the destructor of my derived class UBSan is throwing a SEGV when the SubClass worker thread performs its cleanup and accesses the parent class impl data.
I would expect that since the DerivedClass destructor is blocked waiting for the thread to finish that the unique_ptr is still valid since the BaseClass destructor hasn't been called to free the unique_ptr.
In my debugger, lldb, when I look in the destructor of DerivedClass it shows a valid memory address for impl. However when looking at variables in cleanup_called_by_thread impl shows up as not a valid memory address.
class BaseClass {
std::unique_ptr<ImplData> impl;
};
class DerivedClass : BaseClass {
~DerivedClass() {
// blocks while the thread cleans up
// thread has exited when this returns and no longer
// accesses this object
this->thread->stop();
}
// Called by thread during cleanup
void cleanup_called_by_thread() {
// this->impl shows as an invalid memory location
ImplData* data = this->impl.get(); // SEGV
}
}
When I print out the address of this in the cleanup func I get a totally different address then I do when i print out the address of this in the destructor.
~DerivedClass() {
// this = 0x6356caca5470
}
DerivedClass::cleanup_called_by_thread() {
// this = 0xa6deb54
}
Anyways I'm a noob at this but loving the different *sans, have already cleaned up a number of things since integrating them this week.