Bug 51790 - Setting system clock back prevents application from exiting
Summary: Setting system clock back prevents application from exiting
Alias: None
Product: Runtime
Classification: Mono
Component: io-layer ()
Version: 4.8.0 (C9)
Hardware: PC Linux
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
Depends on:
Reported: 2017-01-26 15:37 UTC by Brandon White
Modified: 2017-09-07 20:31 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

minimal reproducing program (4.93 KB, application/x-7z-compressed)
2017-01-26 15:37 UTC, Brandon White

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Brandon White 2017-01-26 15:37:04 UTC
Created attachment 19489 [details]
minimal reproducing program

On Linux if Task.Delay is used and then the system clock is adjusted back in time, even slightly, then the application can no longer exit.  The runtime will remain locked up, and the process must be forcibly killed.

Attached is a minimal reproducing program.  To observe the issue, run the application on Linux.  Confirm that you see "Tick.Tock." every second or so.  Then change your system time back by some amount (several seconds or minutes is sufficient).

- Note that the program output then unexpectedly stops.
- Issue a keypress in the program's console.  Note that the program outputs "Exiting...".
- At this point program's Main() has returned, however the runtime does not exit the process.
- The process must then be forcibly killed, **or** if you wait for the time to "catch back up" (that is, for system time to elapse forward by the amount that you adjusted it backward) then the process will finally exit on its own.

This issue does not occur in Windows with the MS .NET framework.

Test enviroment:

Mono JIT compiler version 4.8.0 (Stable Tue Jan 24 13:23:36 UTC 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen
Comment 1 Brandon White 2017-09-07 20:31:43 UTC
I can confirm that this is resolved in Mono 5.2!