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

System.Threading.Timer uses wrong TimeSpan property for "period" on linux-bionic-arm native aot #100332

Closed
emmauss opened this issue Mar 27, 2024 · 1 comment

Comments

@emmauss
Copy link

emmauss commented Mar 27, 2024

Description

The following code snippet crashes when run in both executable mode and as a shared library, being build for linux-bionic-arm with native aot.

var timer = new Timer(_ =>
{

}, null, TimeSpan.FromMilliseconds(60), Timeout.InfiniteTimeSpan);

The crash log;

Unhandled exception. System.ArgumentOutOfRangeException: period ('-10000') must be greater than or equal to '-1'. (Parameter 'period')
Actual value was -10000.
   at System.ArgumentOutOfRangeException.ThrowLess[T](T, T, String) + 0x103
   at System.ArgumentOutOfRangeException.ThrowIfLessThan[T](T, T, String) + 0x43
   at System.Threading.Timer..ctor(TimerCallback, Object, TimeSpan, TimeSpan) + 0xdb
   at Program.Main(String[] args) + 0x301

Reproduction Steps

Reproduction can be found here, https://github.com/emmauss/test-aot/blob/main/Program.cs
Publish with linux-bionic-arm as rid and run in termux.

Expected behavior

No crash.

Actual behavior

Crashes with the reported exception.

Regression?

No response

Known Workarounds

Using the Timer constructor that accepts a long as value for period works.

Configuration

Runtime version: 9.0.0-preview.4.24174.6
OS: Android 13
Arch: ARM on ARM64

Other information

Though not being able to reproduce, I also encounter a bug where (TimeSpan.Zero).TotalMilliseconds >= 0.0 is false. This is in a very large project, but doesn't happen in the repro provided above. The above repro is running on an ARM64 OS in ARM mode.

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Mar 27, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Mar 27, 2024
@MichalStrehovsky MichalStrehovsky added os-android area-NativeAOT-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Mar 27, 2024
@emmauss
Copy link
Author

emmauss commented Apr 2, 2024

Closing, as fixed by #100392

@emmauss emmauss closed this as completed Apr 2, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Apr 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

No branches or pull requests

2 participants