firecracker: [Bug] Processes get stuck after resuming VM from snapshot
Describe the bug
After resuming a VM from snapshot, processes occasionally get stuck. A minimal example is an init binary that just runs while (true) { sleep 100ms ; print 'hello' } - after resuming from snapshot, it only sometimes is able to resume the loop, and other times it gets stuck and does not print anything at all.
To Reproduce
- Clone the following repo, which has the minimal code needed to reproduce: https://github.com/bduffany/firecracker-sleep-issue
- Make sure you have
make,cc(C compiler, fromgccpackage),glibc-static(for statically linking the init binary), andjq(for parsing firecracker API output) - Run
make test
make test is doing the following:
- Fetches the firecracker v1.4.0 release binary from GitHub as well as vmlinux 4.14 from the https://github.com/firecracker-microvm/firecracker-demo repo
- Runs firecracker with an initrd where the init binary just loops infinitely, printing “running” then sleeping for 100ms.
- Streams the VM logs to the kernel (using
tail -fin the background) - Every 1s, pauses the VM, takes a snapshot, then kills firecracker (SIGTERM), then restarts firecracker, resuming the VM from snapshot.
Expected behaviour
When running make test in that repo, the init binary should print running several times after each resume. But on some resumes, it appears stuck, and does not print anything until the next resume.
Interesting details:
- The issue does NOT reproduce if I replace the
nanosleepsyscalls with an NOP loop of 1e9 iterations (for (int i=0; i<1e9; i++) continue;) - The issue seems specific to snapshotting, not just pausing and resuming the VM. I tried just doing pause/resume without taking a snapshot and then restarting the
firecrackerbinary in between, but could not reproduce. - I could not reproduce this on an Intel CPU so far, only AMD (have tried 2 different Intel machines and 2 different AMD machines).
Environment
- Firecracker v1.4.0
- Host kernel v6.2.0 (Ubuntu 22.04)
- UPDATE: also reproduced on host kernel v5.10 -
m6a.metalinstance
- UPDATE: also reproduced on host kernel v5.10 -
- Guest kernel 4.14.55-84.37.amzn2.x86_64, from https://github.com/firecracker-microvm/firecracker-demo
- Also tried compiling 5.10 using the recommended guest config - the issue still reproduces.
- Rootfs: none (initrd only)
- Architecture: x86_64 (AMD Ryzen CPU)
- UPDATE: Also reproduced with AMD EPYC (
m6a.metalinstance)
- UPDATE: Also reproduced with AMD EPYC (
- GLIBC 2.35 (for init binary)
Additional context
This repro above is a minimal example of a much more troublesome issue where we are having trouble reconnecting to microVMs after resuming them from snapshots. We are running a server inside the VM and are having trouble connecting to over vsock. I suspected that the guest process was “stuck” somehow since when running sleep 1 && print('hello') in a background loop, it sometimes doesn’t print anything. I came up with this minimal reproducer for this behavior.
Checks
- Have you searched the Firecracker Issues database for similar problems?
- https://github.com/firecracker-microvm/firecracker/issues/3020 - not sure if this is related, but it was closed without resolution. The final comment said to re-open if it could be reproduced with a supported kernel version
- Have you read the existing relevant Firecracker documentation?
- I have read the FAQ about guest clock drift / NTP, but this appears more significant than just clock drift since I think nanosleep should work based on relative timing? I could be wrong, though.
- Are you certain the bug being reported is a Firecracker issue?
- Not 100% certain, but given that it happens only when loading a snapshot, it seems like it could be Firecracker-related
About this issue
- Original URL
- State: open
- Created 10 months ago
- Reactions: 2
- Comments: 23 (20 by maintainers)
Hi @bduffany. We are still working on the root cause of this issue. We will update you as soon as possible.
Hi @bduffany,
Sorry for the delay, unfortunately we were not able to make progress regarding this issue. We are still tracking the problem and will provide an update once we will have more data to share.
Hi @bduffany, I am currently looking at this. I found that passing
lapic=notscdeadlinein the kernel boot command line also seems to fix it, so I think that narrows it down a bit. I will continue investigating, but could you confirm?Hi @bduffany, thanks for providing the repro steps. We are working on this issue and to provide an update :
Ah OK, I will actually just spin one of those up on AWS then 😃 Thanks
Yes. m6a.metal is AMD instance that firecracker is tested on. Thanks for your help and effort!