malloc debug: reset FreeTrackData mutex after fork
Lock the FreeTrackData mutex during fork and reset it in the child. Ensures that the FreeTrackData is consistent when forking from a multi-threaded process, and that the mutex is in a defined state in the child. Test: 89hours MTBF test Change-Id: I5e5892832a733ea85727ec65abc7094d95a725ef
This commit is contained in:
parent
d16b09a4d2
commit
1a8106ec1a
2 changed files with 15 additions and 0 deletions
|
@ -94,16 +94,25 @@ void DebugData::PrepareFork() {
|
|||
if (track != nullptr) {
|
||||
track->PrepareFork();
|
||||
}
|
||||
if (free_track != nullptr) {
|
||||
free_track->PrepareFork();
|
||||
}
|
||||
}
|
||||
|
||||
void DebugData::PostForkParent() {
|
||||
if (track != nullptr) {
|
||||
track->PostForkParent();
|
||||
}
|
||||
if (free_track != nullptr) {
|
||||
free_track->PostForkParent();
|
||||
}
|
||||
}
|
||||
|
||||
void DebugData::PostForkChild() {
|
||||
if (track != nullptr) {
|
||||
track->PostForkChild();
|
||||
}
|
||||
if (free_track != nullptr) {
|
||||
free_track->PostForkChild();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,12 @@ class FreeTrackData : public OptionData {
|
|||
|
||||
void LogBacktrace(const Header* header);
|
||||
|
||||
void PrepareFork() { pthread_mutex_lock(&mutex_); }
|
||||
|
||||
void PostForkParent() { pthread_mutex_unlock(&mutex_); }
|
||||
|
||||
void PostForkChild() { pthread_mutex_init(&mutex_, NULL); }
|
||||
|
||||
private:
|
||||
void LogFreeError(const Header* header, const uint8_t* pointer);
|
||||
void VerifyAndFree(const Header* header);
|
||||
|
|
Loading…
Reference in a new issue