Merge "libutils: ~RefBase more logs" am: 83785021f7
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2021996 Change-Id: Ife6f4d6c811cd7c889688eb3f2dea8a9311c2099
This commit is contained in:
commit
976ee88aac
1 changed files with 9 additions and 12 deletions
|
|
@ -50,11 +50,6 @@
|
||||||
// log all reference counting operations
|
// log all reference counting operations
|
||||||
#define PRINT_REFS 0
|
#define PRINT_REFS 0
|
||||||
|
|
||||||
// Continue after logging a stack trace if ~RefBase discovers that reference
|
|
||||||
// count has never been incremented. Normally we conspicuously crash in that
|
|
||||||
// case.
|
|
||||||
#define DEBUG_REFBASE_DESTRUCTION 1
|
|
||||||
|
|
||||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||||
// CallStack is only supported on linux type platforms.
|
// CallStack is only supported on linux type platforms.
|
||||||
#define CALLSTACK_ENABLED 1
|
#define CALLSTACK_ENABLED 1
|
||||||
|
|
@ -751,16 +746,18 @@ RefBase::~RefBase()
|
||||||
}
|
}
|
||||||
} else if (mRefs->mStrong.load(std::memory_order_relaxed) == INITIAL_STRONG_VALUE) {
|
} else if (mRefs->mStrong.load(std::memory_order_relaxed) == INITIAL_STRONG_VALUE) {
|
||||||
// We never acquired a strong reference on this object.
|
// We never acquired a strong reference on this object.
|
||||||
#if DEBUG_REFBASE_DESTRUCTION
|
|
||||||
// Treating this as fatal is prone to causing boot loops. For debugging, it's
|
// TODO: make this fatal, but too much code in Android manages RefBase with
|
||||||
// better to treat as non-fatal.
|
// new/delete manually (or using other mechanisms such as std::make_unique).
|
||||||
ALOGD("RefBase: Explicit destruction, weak count = %d (in %p)", mRefs->mWeak.load(), this);
|
// However, this is dangerous because it's also common for code to use the
|
||||||
|
// sp<T>(T*) constructor, assuming that if the object is around, it is already
|
||||||
|
// owned by an sp<>.
|
||||||
|
ALOGW("RefBase: Explicit destruction, weak count = %d (in %p). Use sp<> to manage this "
|
||||||
|
"object.",
|
||||||
|
mRefs->mWeak.load(), this);
|
||||||
|
|
||||||
#if CALLSTACK_ENABLED
|
#if CALLSTACK_ENABLED
|
||||||
CallStack::logStack(LOG_TAG);
|
CallStack::logStack(LOG_TAG);
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
LOG_ALWAYS_FATAL("RefBase: Explicit destruction, weak count = %d", mRefs->mWeak.load());
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// For debugging purposes, clear mRefs. Ineffective against outstanding wp's.
|
// For debugging purposes, clear mRefs. Ineffective against outstanding wp's.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue