Task.Delay hangs indefinitely on Linux ARM32 when system clock is set backwards (.NET 10 regression)
Description
Task.Delay hangs when system clock is set backwards (.NET 10 regression)
Description
Task.Delay() hangs when the system clock is set backwards on Linux ARM32. This is a regression from .NET 9.
Reproduction
- Run
await Task.Delay(10000)on Linux ARM32 - While waiting, set the system clock backwards
- Expected: Delay completes in ~10 seconds
- Actual: Delay hangs forever
Regression
- .NET 9: ✅ Works correctly
- .NET 10.0.1: ❌ Hangs/extends when clock set backwards
Environment
Tested on two Raspberry Pi CM4S systems:
| System 1 | System 2 | |
|---|---|---|
| OS | Buildroot 2024.02 | Buildroot 2025.02.7 |
| Kernel | 5.10.92-v7l | 6.6.78-v7l |
| glibc | - | 2.41 |
| Arch | armv7l (32-bit) | armv7l (32-bit) |
| .NET | 10.0.1 | 10.0.1 |
| Result | ❌ Hangs | ❌ Hangs |
## Impact
Affects embedded/IoT systems where clock may be adjusted (NTP sync, RTC drift, etc.). All timer-based APIs affected: `Task.Delay`, others ??.
### Reproduction Steps
## Reproduction
1. Run `await Task.Delay(10000)` on Linux ARM32
2. While waiting, set the system clock backwards
3. **Expected**: Delay completes in ~10 seconds
4. **Actual**: Delay hangs forever
### Expected behavior
3. **Expected**: Delay completes in ~10 seconds
### Actual behavior
4. **Actual**: Delay hangs forever
### Regression?
It works as expected with .Net 9.
### Known Workarounds
Revert to dotnet 9.
### Configuration
## Environment
Tested on two Raspberry Pi CM4S systems:
| | System 1 | System 2 |
|---|---|---|
| **OS** | Buildroot 2024.02 | Buildroot 2025.02.7 |
| **Kernel** | 5.10.92-v7l | 6.6.78-v7l |
| **glibc** | - | 2.41 |
| **Arch** | armv7l (32-bit) | armv7l (32-bit) |
| **.NET** | 10.0.1 | 10.0.1 |
| **Result** | ❌ Hangs | ❌ Hangs |
### Other information
_No response_
namespace ConsoleApp9;
public static class Program
{
public static async Task Main()
{
int index = 0;
while (true)
{
index++;
Console.WriteLine($"Iteration {index}");
await Task.Delay(1000); // Hangs when system date is set back in time.
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net10.0\publish\linux-arm\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net10.0</TargetFramework>
<RuntimeIdentifier>linux-arm</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>
</Project>
- Have you been able to test this with any other Linux distros, or even Windows?
- Is this a completely indefinite hang, or is it "hangs until the clock catches up to the new time offset"? That is, if you set the clock back 5 minutes, does it wait for 5 minutes and 10 seconds, or does it never complete?
- The bug do not happen on Linux x64 (Ubuntu)
- It hangs forever.
Hello,
We have the same bug also on Linux arm64.
@Clockwork-Muse: In our tests, it "hangs until the clock catches up to the new time offset".
Downgrading our application back to .NET 9 fixes the issue also for us.
We've also encountered this while developing a Linux-based medical device. We can reproduce this in a generic Ubuntu VM.
I also have this issue in Manjaro x64 and on Yocto using a 6.11 ARM32 Kernel. I'm pretty sure the system thaws again when it reaches the original time point plus the sleep duration. Looks like the runtime is using a wall clock rather than a monotonic clock.
I encountered the same behaviour with every kind of wait: Thread.Sleep, PerodicTimer, System.Threading.Timer,... See related issue.
Windows does not show this effect
Duplicate of #123950 that has more context.