aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.arch/s390-stackless.exp
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2023-12-06 11:16:49 +0000
committerAndrew Burgess <aburgess@redhat.com>2023-12-06 11:25:00 +0000
commit5a22e042e41db962cd6a79cd59cab46cbbe58a98 (patch)
tree4ddb9b699a647e44d58b082ed33f38443478dab7 /gdb/testsuite/gdb.arch/s390-stackless.exp
parentb17ef9dcd8d16eedf4e60565cd7701698b5a0b6b (diff)
downloadgdb-5a22e042e41db962cd6a79cd59cab46cbbe58a98.zip
gdb-5a22e042e41db962cd6a79cd59cab46cbbe58a98.tar.gz
gdb-5a22e042e41db962cd6a79cd59cab46cbbe58a98.tar.bz2
gdb: fix libstdc++ assert caused by invalid use of std::clamp
After this commit: commit 33ae45434d0ab1f7de365b9140ad4e4ffc34b8a2 Date: Mon Dec 4 14:23:17 2023 +0000 gdb: Enable early init of thread pool size I am now seeing this assert from libstdc++: /usr/include/c++/9/bits/stl_algo.h:3715: constexpr const _Tp& std::clamp(const _Tp&, const _Tp&, const _Tp&) [with _Tp = int]: Assertion '!(__hi < __lo)' failed. This may only be visible because I compile with: -D_GLIBCXX_DEBUG=1 -D_GLIBCXX_DEBUG_PEDANTIC=1 but I haven't checked. The issue the assert is highlighting is real, and is caused by this block of code: if (n_threads < 0) { const int hardware_threads = std::thread::hardware_concurrency (); /* Testing in #29959 indicates that parallel efficiency drops between n_threads=5 to 8. Therefore, clamp the default value to 8 to avoid an excessive number of threads in the pool on many-core systems. */ const int throttle = 8; n_threads = std::clamp (hardware_threads, hardware_threads, throttle); } The arguments to std::clamp are VALUE, LOW, HIGH, but in the above, if we have more than 8 hardware threads available the LOW will be greater than the HIGH, which is triggering the assert I see above. I believe std::clamp is the wrong tool to use here. Instead std::min would be a better choice; we want the smaller value of HARDWARE_THREADS or THROTTLE. If h/w threads is 2, then we want 2, but if h/w threads is 16 we want 8, this is what std::min gives us. After this commit, I no longer see the assert.
Diffstat (limited to 'gdb/testsuite/gdb.arch/s390-stackless.exp')
0 files changed, 0 insertions, 0 deletions