////

Integer overflow in chrono/duration conversion silently zeroing a configured timeout

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 nor

////

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++ 정수 오버플로 동작 규칙은 불변이고, 포화 연산·상한 클램핑 권장안도 현재 최선 관행과 일치한다.

Reviews

Support
0
Dispute
0
Neutral
0
Visible Reviews
1