Summary#
When a large user-configured microsecond timeout is converted through a chrono or std::duration chain, an intermediate cast can overflow and produce zero (or a very small value), making the system behave as if no wait is configured. The bug is invisible in normal operation because most real workloads use moderate timeouts that fit safely in the narrower type.
Problem#
memory_usage_overcommit_max_wait_microseconds was converted via a path that overflowed the intermediate integer type, silently replacing the configured wait with 0 and causing immediate overcommit rejection instead of the expected wait.
Solution#
Use saturating or checked arithmetic at every duration conversion boundary. Clamp before narrowing: std::min(value, max_representable) rather than letting the cast wrap. Add a unit test with a value just below and just above the narrowing boundary.
Failure Modes#
- Overflow wraps to a non-zero but wrong value on signed types, making the bug even harder to detect
- Bug only triggers for users who explicitly set a large timeout; default values fit in the narrower type
- Compiler warnings about narrowing may be suppressed project-wide, hiding the site
Sources#
- https://github.com/tensorflow/tensorflow/pull/127204
- https://github.com/tensorflow/tensorflow/pull/127251
- https://github.com/huggingface/transformers/pull/48516
- https://github.com/huggingface/transformers/pull/48155
- https://github.com/huggingface/transformers/pull/48685
- https://github.com/huggingface/transformers/pull/40546
- https://github.com/huggingface/transformers/pull/48720
- https://github.com/huggingface/transformers/pull/48689
- https://github.com/huggingface/transformers/pull/44314
- https://github.com/huggingface/transformers/pull/46419
- https://github.com/huggingface/transformers/pull/48684
- https://github.com/microsoft/ML-For-Beginners/pull/1002
- https://github.com/microsoft/ML-For-Beginners/pull/1001
- https://github.com/microsoft/ML-For-Beginners/pull/1000
- https://github.com/ClickHouse/ClickHouse/pull/117998
- https://github.com/ClickHouse/ClickHouse/pull/117997
- https://github.com/ClickHouse/ClickHouse/pull/119737
- https://github.com/ClickHouse/ClickHouse/pull/118005
- https://github.com/ClickHouse/ClickHouse/pull/118023
- https://github.com/ClickHouse/ClickHouse/pull/119676
- https://github.com/ClickHouse/ClickHouse/pull/118183
- https://github.com/ClickHouse/ClickHouse/pull/118057
- https://github.com/ClickHouse/ClickHouse/pull/118046
- https://github.com/ClickHouse/ClickHouse/pull/118108
- https://github.com/ClickHouse/ClickHouse/pull/118137
- https://github.com/ClickHouse/ClickHouse/pull/119348
- https://github.com/ClickHouse/ClickHouse/pull/118297
- https://github.com/ClickHouse/ClickHouse/pull/118227
- https://github.com/ClickHouse/ClickHouse/pull/118221
- https://github.com/rustfs/rustfs/pull/7729
- https://github.com/rustfs/rustfs/pull/7731
- https://github.com/rustfs/rustfs/pull/7739
- https://github.com/rustfs/rustfs/pull/7738
- https://github.com/rustfs/rustfs/pull/7734
- https://github.com/rustfs/rustfs/pull/7728
- https://github.com/rustfs/rustfs/pull/7726
- https://github.com/rustfs/rustfs/pull/7724
- https://github.com/rustfs/rustfs/pull/7723
- https://github.com/rustfs/rustfs/pull/7712
- https://github.com/rustfs/rustfs/pull/7722
- https://github.com/rustfs/rustfs/pull/7721
- https://github.com/rustfs/rustfs/pull/7720
- https://github.com/rustfs/rustfs/pull/7719
- https://github.com/rustfs/rustfs/pull/7718
- mined_at: 2026-09-13T07:06:13Z
Sagwan Revalidation 2026-09-13T07:43:23Z#
- verdict:
ok - note: C++ 정수 오버플로 동작 규칙은 불변이고, 포화 연산·상한 클램핑 권장안도 현재 최선 관행과 일치한다.
Sagwan Revalidation 2026-09-16T23:55:11Z#
- verdict:
ok - note: 핵심 주장과 권장안은 현재 검증 결과와 기존 지지 리뷰에 부합한다.
Sagwan Revalidation 2026-09-19T19:15:16Z#
- verdict:
ok - note: 정수 오버플로 위험과 클램프 권장안은 여전히 유효하다.
Sagwan Revalidation 2026-09-28T08:40:18Z#
- verdict:
refresh - note: 부호 있는 정수의 오버플로를 래핑으로 단정하고, 변환 전 클램핑 설명도 불충분해 수정이 필요하다.
Sagwan Revalidation 2026-10-02T12:41:54Z#
- verdict:
refresh - note: 부호 있는 정수 오버플로를 래핑으로 단정하고, 변환 전 클램핑 설명도 불충분해 수정이 필요하다.
Sagwan Revalidation 2026-10-05T13:35:01Z#
- verdict:
refresh - note: 부호 있는 정수 오버플로를 래핑으로 단정했고, 변환 전 클램핑 방법도 보완이 필요하다.
Sagwan Revalidation 2026-10-08T13:28:16Z#
- verdict:
refresh - note: 부호 있는 정수 오버플로를 래핑으로 단정하고, 변환 전 클램핑 설명도 보완이 필요하다.
Sagwan Revalidation 2026-10-11T07:35:26Z#
- verdict:
refresh - note: 부호 있는 정수 오버플로를 래핑으로 단정했고, 안전한 클램핑 방법도 보완이 필요하다.
Sagwan Revalidation 2026-10-14T01:45:49Z#
- verdict:
refresh - note: 부호 있는 정수 오버플로를 래핑으로 단정했고, 안전한 클램핑 방법도 보완이 필요하다.
Sagwan Revalidation 2026-10-16T22:24:19Z#
- verdict:
refresh - note: 본문 사례와 무관해 보이는 출처 링크가 나열돼 있어 근거를 재확인하고 교체할 가치가 있습니다.
Sagwan Revalidation 2026-10-19T18:28:57Z#
- verdict:
refresh - note: 부호 있는 정수의 오버플로를 래핑으로 단정하고, 사례와 무관한 출처가 섞여 있어 수정이 필요하다.