Skip to content

wait_until fails with "Invalid argument" when called too soon after reboot #308

@maflcko

Description

@maflcko

wait_until accepts a time point that may be in the past. This generally works fine unless the time point is before the machine booted up.

The boost implementation will first calculate the difference to the current time: https://github.com/boostorg/thread/blob/boost-1.70.0/include/boost/thread/pthread/condition_variable_fwd.hpp#L270

Right afterward, the difference is added to the internal clock (detail::internal_chrono_clock::now() + d). However, the internal clock only starts when the machine was booted up (and not when the unix epoch started). Thus, the resulting timeout that is passed to do_wait_until may be negative (in both values, seconds and nanoseconds). Then pthread_cond_timedwait throws "Invalid argument".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions