devices: proxy: ensure device drop gets called

Explicitly drop the device object before calling libc::exit() so that
the Drop impl for the device has a chance to be called.

Change-Id: Id93447925f71340c78a1d80efdff5b1574801409
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3900327
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Daniel Verkamp 2022-09-15 14:26:43 -07:00 committed by crosvm LUCI
parent 8e0a4cb345
commit 835a85b983

View file

@ -201,6 +201,10 @@ impl ProxyDevice {
device.on_sandboxed();
child_proc(child_tube, &mut device);
// Explicitly drop the device so that its Drop implementation has a chance to run
// before the call to `libc::exit()`.
std::mem::drop(device);
// We're explicitly not using std::process::exit here to avoid the cleanup of
// stdout/stderr globals. This can cause cascading panics and SIGILL if a worker
// thread attempts to log to stderr after at_exit handlers have been run.