)]}'
{
  "commit": "5a22e042e41db962cd6a79cd59cab46cbbe58a98",
  "tree": "4ddb9b699a647e44d58b082ed33f38443478dab7",
  "parents": [
    "b17ef9dcd8d16eedf4e60565cd7701698b5a0b6b"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Wed Dec 06 11:16:49 2023 +0000"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Wed Dec 06 11:25:00 2023 +0000"
  },
  "message": "gdb: fix libstdc++ assert caused by invalid use of std::clamp\n\nAfter this commit:\n\n  commit 33ae45434d0ab1f7de365b9140ad4e4ffc34b8a2\n  Date:   Mon Dec 4 14:23:17 2023 +0000\n\n      gdb: Enable early init of thread pool size\n\nI am now seeing this assert from libstdc++:\n\n  /usr/include/c++/9/bits/stl_algo.h:3715: constexpr const _Tp\u0026 std::clamp(const _Tp\u0026, const _Tp\u0026, const _Tp\u0026) [with _Tp \u003d int]: Assertion \u0027!(__hi \u003c __lo)\u0027 failed.\n\nThis may only be visible because I compile with:\n\n  -D_GLIBCXX_DEBUG\u003d1 -D_GLIBCXX_DEBUG_PEDANTIC\u003d1\n\nbut I haven\u0027t checked.  The issue the assert is highlighting is real,\nand is caused by this block of code:\n\n  if (n_threads \u003c 0)\n    {\n      const int hardware_threads \u003d std::thread::hardware_concurrency ();\n      /* Testing in #29959 indicates that parallel efficiency drops between\n         n_threads\u003d5 to 8.  Therefore, clamp the default value to 8 to avoid an\n         excessive number of threads in the pool on many-core systems.  */\n      const int throttle \u003d 8;\n      n_threads \u003d std::clamp (hardware_threads, hardware_threads, throttle);\n    }\n\nThe arguments to std::clamp are VALUE, LOW, HIGH, but in the above, if\nwe have more than 8 hardware threads available the LOW will be greater\nthan the HIGH, which is triggering the assert I see above.\n\nI believe std::clamp is the wrong tool to use here.  Instead std::min\nwould be a better choice; we want the smaller value of\nHARDWARE_THREADS or THROTTLE.  If h/w threads is 2, then we want 2,\nbut if h/w threads is 16 we want 8, this is what std::min gives us.\n\nAfter this commit, I no longer see the assert.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "2e6754c95581dc96e1c27c7cb7b900556b53bc26",
      "old_mode": 33188,
      "old_path": "gdb/maint.c",
      "new_id": "68b70bf403d325d0b9d253137192a55562cccd9a",
      "new_mode": 33188,
      "new_path": "gdb/maint.c"
    }
  ]
}
