dfalling
Elixir Crashes in Virtualbox with monotonic time message
I’m running Elixir/Phoenix in a VirtualBox instance. After a short period of time (typically 5 minutes or so), Elixir quits with this output:
Monotonic time stepped backwards!
Previous time: 2140883699436
Current time: 2140883692221
[os_mon] cpu supervisor port (cpu_sup): Erlang has closed
[os_mon] memory supervisor port (memsup): Erlang has closed
zsh: IOT instruction (core dumped) mix phx.server
I can’t find any sort of erlang crash log. What should I do to troubleshoot this crash? At the time of the crash I have plenty of memory and swap available.
VM OS: Lubuntu 22.04.1 LTS
VM Memory: 2GB
VM Swap: 2GB
Elixir: 1.14.0
Erlang: 25.0.4
Marked As Solved
itopiz
This was indeed an issue with VirtualBox and it has been fixed (#22334 (VM clock goes backwards => fixed in svn) – Oracle VirtualBox). Waiting for a new VirtualBox release now.
Also Liked
derek-zhou
At its core the BEAM is a preemptive multi-threaded system. So if the clock is funky then the scheduling will not be fair. If the clock warp too much then I guess some GenServer calls could even timeout.
tcoopman
The issue is that your VM turned back in time, which erlang doesn’t like.
After reading a bit more on this, I also found this which says disabling time correction is the solution: Passing erl options to erlc? - #7 by rickard - Questions / Help - Erlang Programming Language Forum - Erlang Forums
Reading the time and correction module in Erlang was not entirely clear, but I think all the time warping is about the erlang monotonic time and not the OS monotonic time.
tcoopman
When searching for virtualbox and monotonic time you find some issues. For example https://www.virtualbox.org/ticket/7915
It’s a very old issue. Although there might still be issues around?
stevensonmt
Did you look at the Time Warp flags in that post I linked about Erlang time? In particular this seems maybe applicable:
+C single_time_warpThis is a special hybrid mode to be used on embedded hardware when you know Erlang boots before the OS clock is synchronized. It works in two phases:
- a.(with
+c true) When the system boots, the monotonic clock is kept as stable as possible, but no system time adjustments are made
b. (with+c false) Same asno_time_warp- The user calls
erlang:system_flag(time_offset, finalize), the Erlang system time warps once to match the OS system time, and then the clocks become equivalent to those underno_time_warp.
dfalling
Aah, I’m sorry. I read your comment and quote but didn’t follow the link. That sounds exactly like what I want. I have it running right now and no crashes so far.
To summarize what I’m trying, it’s elixir --erl "+c false" -S mix phx.server. The description sounds like exactly what I want:
If the OS system time jumps backwards, the Erlang Monotonic clock stalls until the OS system time jumps back forward, which can take a while.
Erlang’s clock stalling for a bit is much better (in my dev environment) than the whole thing crashing.
Thank you! I’ll report back here if it ends up dying eventually, but it looks promising.







