An ipc client can pass any timeout to waitTipChanged, but the code assumes it is never negative:
Assume(timeout >= 0ms); // No internal callers should use a negative timeout
On debug builds, a negative or NaN timeout fails this check and aborts the node. I reproduced this with a timeout of -1.0.
On release builds the check is skipped. Negative values are clamped to zero, but NaN is not, because every comparison with NaN is false. It ends up as the deadline passed to wait_until.
waitNext has no Assume, but it also doesn't check its timeout. A NaN timeout waits one extra fee tick (about one second) before returning.
waitTipChanged and waitNext now throw an error for negative or NaN timeouts. The internal Assume in WaitTipChanged still checks internal callers. The interface documents the errors, and the functional test covers rejection of negative and NaN timeouts and acceptance of positive infinity in both methods.
I'm not aware of any client that sends these values (sv2-tp, for example, requires an interval of at least one second), so this is hardening against bad input from ipc clients.
This is similar to #36520, which handles invalid arguments to the Chain interface for the same reason.
Links
<!-- *** Please remove the following help text before submitting: *** Pull requests may be closed immediately if they: - do not have a rationale and clear improvement - do not adhere to doc/AI_POLICY.md GUI-related pull requests should be opened against https://github.com/bitcoin-core/gui first. See CONTRIBUTING.md -->
<!-- Please provide clear motivation for your patch and explain how it improves Bitcoin Core user experience or Bitcoin Core developer experience significantly: * Any test improvements or new tests that improve coverage are always welcome. * All other changes should have accompanying unit tests (see `src/test/`) or functional tests (see `test/`). Contributors should note which tests cover modified code. If no tests exist for a region of modified code, new tests should accompany the change. * Bug fixes are most welcome when they come with steps to reproduce or an explanation of the potential issue as well as reasoning for the way the bug was fixed. * Features are welcome, but might be rejected due to design or scope issues. If a feature is based on a lot of dependencies, contributors should first consider building the system outside of Bitcoin Core, if possible. * Refactoring changes are only accepted if they are required for a feature or bug fix or otherwise improve developer experience significantly. For example, most "code style" refactoring changes require a thorough explanation why they are useful, what downsides they have and why they *significantly* improve developer experience or avoid serious programming bugs. Note that code style is often a subjective matter. Unless they are explicitly mentioned to be preferred in the [developer notes](/doc/developer-notes.md), stylistic code changes are usually rejected. -->
<!-- Bitcoin Core has a thorough review process and even the most trivial change needs to pass a lot of eyes and requires non-zero or even substantial time effort to review. There is a huge lack of active reviewers on the project, so patches often sit for a long time. -->