Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c/tests: avoid ubsan signed integer overflow #24133

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Commits on Nov 14, 2024

  1. c/tests: avoid ubsan signed integer overflow

    Before the change ubsan would assert on a signed integer overflow
    ```
    /vectorized/llvm/bin/../include/c++/v1/__chrono/duration.h:92:79: runtime error: signed integer overflow: 9223372036854775807 * 1000 cannot be represented in type '_Ct' (aka 'long long')
    cluster::tx::producer_state_manager::evict_excess_producers() at /vectorized/llvm/bin/../include/c++/v1/__chrono/duration.h:92
    ```
    
    The problem lies in that we try to subtract duration from a time_point
    with nanosecond granularity. When doing that, duration is converted to a
    common type, nanosecond representation and the millisecond::max() being
    already maximum value that can be represented in a long long can't be
    converted to micros (multiplied by 1000).
    
    Not sure if this is the perfect fix but avoid the problem by
    initializing the duration with a value that can be later represented as
    micros.
    nvartolomei committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    3f260ea View commit details
    Browse the repository at this point in the history