mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 20:30:41 +00:00
Bug 1536129 - Fix !MOZ_CALLSTACK_DISABLED blocking resource acquisition checking, r=erahm
Differential Revision: https://phabricator.services.mozilla.com/D23882 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
2c33b42b2c
commit
6bf4c529b1
@ -52,7 +52,7 @@ void BlockingResourceBase::StackWalkCallback(uint32_t aFrameNumber, void* aPc,
|
||||
void* aSp, void* aClosure) {
|
||||
# ifndef MOZ_CALLSTACK_DISABLED
|
||||
AcquisitionState* state = (AcquisitionState*)aClosure;
|
||||
state->AppendElement(aPc);
|
||||
state->ref().AppendElement(aPc);
|
||||
# endif
|
||||
}
|
||||
|
||||
@ -61,11 +61,16 @@ void BlockingResourceBase::GetStackTrace(AcquisitionState& aState) {
|
||||
// Skip this function and the calling function.
|
||||
const uint32_t kSkipFrames = 2;
|
||||
|
||||
aState.Clear();
|
||||
// Clear the array...
|
||||
aState.reset();
|
||||
// ...and create a new one; this also puts the state to 'acquired' status
|
||||
// regardless of whether we obtain a stack trace or not.
|
||||
aState.emplace();
|
||||
|
||||
// NB: Ignore the return value, there's nothing useful we can do if this
|
||||
// this fails.
|
||||
MozStackWalk(StackWalkCallback, kSkipFrames, 24, &aState);
|
||||
MozStackWalk(StackWalkCallback, kSkipFrames, kAcquisitionStateStackSize,
|
||||
aState.ptr());
|
||||
# endif
|
||||
}
|
||||
|
||||
@ -173,10 +178,10 @@ bool BlockingResourceBase::Print(nsACString& aOut) const {
|
||||
|
||||
WalkTheStackCodeAddressService addressService;
|
||||
|
||||
for (uint32_t i = 0; i < state.Length(); i++) {
|
||||
for (uint32_t i = 0; i < state.ref().Length(); i++) {
|
||||
const size_t kMaxLength = 1024;
|
||||
char buffer[kMaxLength];
|
||||
addressService.GetLocation(i + 1, state[i], buffer, kMaxLength);
|
||||
addressService.GetLocation(i + 1, state.ref()[i], buffer, kMaxLength);
|
||||
const char* fmt = " %s\n";
|
||||
aOut.AppendLiteral(" ");
|
||||
aOut.Append(buffer);
|
||||
@ -298,7 +303,9 @@ void BlockingResourceBase::Acquire() {
|
||||
# else
|
||||
// Take a stack snapshot.
|
||||
GetStackTrace(mAcquired);
|
||||
if (mFirstSeen.IsEmpty()) {
|
||||
MOZ_ASSERT(IsAcquired());
|
||||
|
||||
if (!mFirstSeen) {
|
||||
mFirstSeen = mAcquired;
|
||||
}
|
||||
# endif
|
||||
|
@ -101,7 +101,12 @@ class BlockingResourceBase {
|
||||
# ifdef MOZ_CALLSTACK_DISABLED
|
||||
typedef bool AcquisitionState;
|
||||
# else
|
||||
typedef AutoTArray<void*, 24> AcquisitionState;
|
||||
// Using maybe to use emplacement as the acquisition state flag; we may not
|
||||
// always get a stack trace because of possible stack walk suppression or
|
||||
// errors, hence can't use !IsEmpty() on the array itself as indication.
|
||||
static size_t const kAcquisitionStateStackSize = 24;
|
||||
typedef Maybe<AutoTArray<void*, kAcquisitionStateStackSize> >
|
||||
AcquisitionState;
|
||||
# endif
|
||||
|
||||
/**
|
||||
@ -217,7 +222,7 @@ class BlockingResourceBase {
|
||||
# ifdef MOZ_CALLSTACK_DISABLED
|
||||
mAcquired = false;
|
||||
# else
|
||||
mAcquired.Clear();
|
||||
mAcquired.reset();
|
||||
# endif
|
||||
}
|
||||
|
||||
@ -227,13 +232,7 @@ class BlockingResourceBase {
|
||||
*
|
||||
* *NOT* thread safe. Requires ownership of underlying resource.
|
||||
*/
|
||||
bool IsAcquired() const {
|
||||
# ifdef MOZ_CALLSTACK_DISABLED
|
||||
return mAcquired;
|
||||
# else
|
||||
return !mAcquired.IsEmpty();
|
||||
# endif
|
||||
}
|
||||
bool IsAcquired() const { return (bool)mAcquired; }
|
||||
|
||||
/**
|
||||
* mChainPrev
|
||||
|
Loading…
x
Reference in New Issue
Block a user