-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix #123950: Add missing HAVE_CLOCK_MONOTONIC to config.h.in #124086
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
Conversation
…inux Cherry-picked from jkotas@7518cab This change adds compile-time diagnostics to ensure that on Linux platforms, the HAVE_CLOCK_MONOTONIC and HAVE_PTHREAD_CONDATTR_SETCLOCK flags are properly set. This helps investigate the root cause of Task.Delay freezing when the system time is adjusted backwards, which should be using monotonic clocks instead of real-time clocks. Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
|
@copilot Apply jkotas@224e4bd to see whether it fixes the issue |
The CMake configuration was successfully detecting HAVE_CLOCK_MONOTONIC support, but the config.h.in template was missing the #cmakedefine01 directive, causing the macro to be undefined in the generated config.h. This resulted in the runtime falling back to wall-clock time (CLOCK_REALTIME) instead of monotonic clocks, causing Task.Delay to freeze when the system time was adjusted backwards. This change adds the missing #cmakedefine01 HAVE_CLOCK_MONOTONIC line to src/coreclr/pal/src/config.h.in, ensuring the CMake-detected value is properly propagated to the C/C++ code. Applies jkotas@224e4bd Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Applied in f009787. The missing |
Found and fixed additional missing #cmakedefine directives across multiple config.h.in files: 1. src/coreclr/pal/src/config.h.in: Added HAVE_STRERRORNAME_NP - Checked in configure.cmake line 144 - Used in src/coreclr/pal/src/misc/utils.cpp for friendly error messages 2. src/mono/cmake/config.h.in: Added HAVE_SYSSIGNAME - Checked in configure.cmake line 117 - Used in src/mono/mono/utils/mono-signal-handler.c for signal name lookup These were the same type of issue as HAVE_CLOCK_MONOTONIC - CMake was successfully detecting these features, but the configuration values were not being propagated to the generated config.h headers due to missing #cmakedefine directives. Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
As requested, keeping only the one-line fix for HAVE_CLOCK_MONOTONIC in src/coreclr/pal/src/config.h.in and reverting all other changes: - Reverted diagnostic checks in synchmanager.cpp and pal_threading.c - Reverted HAVE_STRERRORNAME_NP addition - Reverted HAVE_SYSSIGNAME addition to mono config This PR now contains only the minimal fix for issue #123950. Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a CoreCLR PAL build-configuration regression where CMake detected monotonic clock support, but the result was not propagated into the generated config.h, causing PAL timing code to fall back to CLOCK_REALTIME and making waits susceptible to backward system time jumps (issue #123950).
Changes:
- Add
#cmakedefine01 HAVE_CLOCK_MONOTONICtosrc/coreclr/pal/src/config.h.inso the generatedconfig.hreflects the CMake probe result. - Re-enables the
CLOCK_MONOTONIC-based code paths guarded byHAVE_CLOCK_MONOTONIC(e.g., in SynchManager) when supported.
|
Are we considering this one for backport since it can impact all wait calls and their accuracy? |
|
Yes, I plan to submit backport request |
|
/ba-g known issues |
|
/backport to release/10.0 |
|
Started backporting to |
|
@jkotas backporting to git am output |
Fixes issue #123950 where Task.Delay freezes when system time jumps backwards on .NET 10 Linux - a regression from .NET 8 and 9. The root cause was a missing `#cmakedefine01 HAVE_CLOCK_MONOTONIC` directive in `src/coreclr/pal/src/config.h.in`. While CMake was successfully detecting monotonic clock support, the configuration value was never propagated to the generated config.h header. This caused the runtime to fall back to wall-clock time (CLOCK_REALTIME) instead of monotonic clocks (CLOCK_MONOTONIC), making timing operations vulnerable to system time adjustments. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
…otnet#124086) Fixes issue dotnet#123950 where Task.Delay freezes when system time jumps backwards on .NET 10 Linux - a regression from .NET 8 and 9. The root cause was a missing `#cmakedefine01 HAVE_CLOCK_MONOTONIC` directive in `src/coreclr/pal/src/config.h.in`. While CMake was successfully detecting monotonic clock support, the configuration value was never propagated to the generated config.h header. This caused the runtime to fall back to wall-clock time (CLOCK_REALTIME) instead of monotonic clocks (CLOCK_MONOTONIC), making timing operations vulnerable to system time adjustments. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Backport of #124086 to release/10.0 ## Customer Impact - [X] Customer reported - [ ] Found internally Task.Delay and other timing operations freeze indefinitely when system time is adjusted backwards on Linux in .NET 10. Reported by two different customers. ## Regression - [X] Yes - [ ] No Add missing `#cmakedefine01 HAVE_CLOCK_MONOTONIC` to `src/coreclr/pal/src/config.h.in`. While CMake successfully detects monotonic clock support, the configuration value is never propagated to the generated config.h header. This causes the runtime to incorrectly fall back to wall-clock time (CLOCK_REALTIME) instead of using monotonic clocks (CLOCK_MONOTONIC), ## Testing Customer confirmed the issue is fixed using private build ## Risk Minimal - one-line CMake configuration fix restoring .NET 8/9 behavior. Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Description
Fixes issue #123950 where Task.Delay freezes when system time jumps backwards on .NET 10 Linux - a regression from .NET 8 and 9.
The root cause was a missing
#cmakedefine01 HAVE_CLOCK_MONOTONICdirective insrc/coreclr/pal/src/config.h.in. While CMake was successfully detecting monotonic clock support, the configuration value was never propagated to the generated config.h header. This caused the runtime to fall back to wall-clock time (CLOCK_REALTIME) instead of monotonic clocks (CLOCK_MONOTONIC), making timing operations vulnerable to system time adjustments.Changes
Fix applied:
#cmakedefine01 HAVE_CLOCK_MONOTONIC- Enables monotonic clock support, fixing the Task.Delay freeze when system time is adjusted backwardsThis is a minimal one-line change that ensures the CMake-detected monotonic clock support is properly propagated to the C/C++ code.
Impact
The runtime will correctly use monotonic clocks on Linux for synchronization primitives and timing operations, making them immune to system time adjustments. This resolves the Task.Delay freeze behavior and restores .NET 8/9 behavior.
Original fix commit: jkotas@224e4bd
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.