Skip to content

Commit 1202eee

Browse files
committed
Bypass denormals-to-zero assertion when running under Valgrind
Valgrind intentionally does not emulate SSE DAZ/FTZ modes, so the DBL_MIN / 2 == 0.0 check always fails under Valgrind. Detect this at runtime using RUNNING_ON_VALGRIND and skip the assertion. The include is guarded with __has_include so it compiles cleanly on systems without valgrind-dev installed. Fixes #16053
1 parent 62c03d7 commit 1202eee

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

src/soundio/sounddevicenetwork.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
#include <QtDebug>
44

5+
#if __has_include(<valgrind/valgrind.h>)
6+
#include <valgrind/valgrind.h>
7+
#endif
8+
59
#include "control/controlobject.h"
610
#include "engine/sidechain/enginenetworkstream.h"
711
#include "float.h"
@@ -488,10 +492,15 @@ void SoundDeviceNetwork::callbackProcessClkRef() {
488492
// verify if flush to zero or denormals to zero works
489493
// test passes if one of the two flag is set.
490494
volatile double doubleMin = DBL_MIN; // the smallest normalized double
491-
VERIFY_OR_DEBUG_ASSERT(doubleMin / 2 == 0.0) {
492-
qWarning() << "Network Sound: Denormals to zero mode is not working. "
493-
"EQs and effects may suffer high CPU load";
494-
}
495+
#if __has_include(<valgrind/valgrind.h>)
496+
if (RUNNING_ON_VALGRIND) {
497+
qDebug() << "Network Sound: Skipping denormals to zero check: running under Valgrind";
498+
} else
499+
#endif
500+
VERIFY_OR_DEBUG_ASSERT(doubleMin / 2 == 0.0) {
501+
qWarning() << "Network Sound: Denormals to zero mode is not working. "
502+
"EQs and effects may suffer high CPU load";
503+
}
495504
else {
496505
qDebug() << "Network Sound: Denormals to zero mode is working";
497506
}

src/soundio/sounddeviceportaudio.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
#include <float.h>
44

5+
#if __has_include(<valgrind/valgrind.h>)
6+
#include <valgrind/valgrind.h>
7+
#endif
8+
59
#include <QRegularExpression>
610
#include <QThread>
711
#include <QtDebug>
@@ -1032,9 +1036,15 @@ int SoundDevicePortAudio::callbackProcessClkRef(
10321036
// verify if flush to zero or denormals to zero works
10331037
// test passes if one of the two flag is set.
10341038
volatile double doubleMin = DBL_MIN; // the smallest normalized double
1035-
VERIFY_OR_DEBUG_ASSERT(doubleMin / 2 == 0.0) {
1036-
qWarning() << "Denormals to zero mode is not working. EQs and effects may suffer high CPU load";
1037-
} else {
1039+
#if __has_include(<valgrind/valgrind.h>)
1040+
if (RUNNING_ON_VALGRIND) {
1041+
qDebug() << "Skipping denormals to zero check: running under Valgrind";
1042+
} else
1043+
#endif
1044+
VERIFY_OR_DEBUG_ASSERT(doubleMin / 2 == 0.0) {
1045+
qWarning() << "Denormals to zero mode is not working. EQs and effects may suffer high CPU load";
1046+
}
1047+
else {
10381048
qDebug() << "Denormals to zero mode is working";
10391049
}
10401050
}

0 commit comments

Comments
 (0)