Skip to content

Commit

Permalink
Bug 1829983 - Disabled assert that's invalid on Windows r=dthayer
Browse files Browse the repository at this point in the history
  • Loading branch information
justinlink-mozilla committed Jun 15, 2023
1 parent f83bece commit 5cea4db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
14 changes: 14 additions & 0 deletions mozglue/misc/TimeStamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,20 @@ typedef BaseTimeDuration<TimeDurationValueCalculator> TimeDuration;
* Note that, since TimeStamp objects are small, prefer to pass them by value
* unless there is a specific reason not to do so.
*/
#if defined(XP_WIN)
// If this static_assert fails then possibly the warning comment below is no
// longer valid and should be removed.
static_assert(sizeof(TimeStampValue) > 8);
#endif
/*
* WARNING: On Windows, each TimeStamp is represented internally by two
* different raw values (one from GTC and one from QPC) and which value gets
* used for a given operation depends on whether both operands have QPC values
* or not. This duality of values can lead to some surprising results when
* mixing TimeStamps with and without QPC values, such as comparisons being
* non-transitive (ie, a > b > c might not imply a > c). See bug 1829983 for
* more details/an example.
*/
class TimeStamp {
public:
/**
Expand Down
33 changes: 4 additions & 29 deletions xpcom/threads/TimerThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@

using namespace mozilla;

// Bug 1829983 reports an assertion failure that (so far) has only failed once
// in over a month of the assert existing. This #define enables some additional
// output that should get printed out if the assert fails again.
#if defined(XP_WIN) && defined(DEBUG)
# define HACK_OUTPUT_FOR_BUG_1829983
#endif

// Uncomment the following line to enable runtime stats during development.
// #define TIMERS_RUNTIME_STATS

Expand Down Expand Up @@ -684,31 +677,13 @@ TimeStamp TimerThread::ComputeWakeupTimeFromTimers() const {
MOZ_ASSERT(bundleWakeup <= cutoffTime);
}

#ifdef HACK_OUTPUT_FOR_BUG_1829983
const bool assertCondition =
bundleWakeup - mTimers[0].Timeout() <=
ComputeAcceptableFiringDelay(mTimers[0].Delay(), minTimerDelay,
maxTimerDelay);
if (!assertCondition) {
printf_stderr("*** Special TimerThread debug output ***\n");
const int64_t tDMin = minTimerDelay.GetValue();
const int64_t tDMax = maxTimerDelay.GetValue();
printf_stderr("%16llx / %16llx\n", tDMin, tDMax);
const size_t l = mTimers.Length();
for (size_t i = 0; i < l; ++i) {
const Entry& e = mTimers[i];
const TimeStamp tS = e.Timeout();
const TimeStampValue tSV = tS.GetValue();
const TimeDuration d = e.Delay();
printf_stderr("[%5zu] %16llx / %16llx / %d / %d / %16llx\n", i, tSV.GTC(),
tSV.QPC(), (int)tSV.IsNull(), (int)tSV.HasQPC(),
d.GetValue());
}
}
#endif
#if !defined(XP_WIN)
// Due to the fact that, on Windows, each TimeStamp object holds two distinct
// "values", this assert is not valid there. See bug 1829983 for the details.
MOZ_ASSERT(bundleWakeup - mTimers[0].Timeout() <=
ComputeAcceptableFiringDelay(mTimers[0].Delay(), minTimerDelay,
maxTimerDelay));
#endif

return bundleWakeup;
}
Expand Down

0 comments on commit 5cea4db

Please sign in to comment.