From a9ac2b561da76ed44e54b48f7683630af00e0c07 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 29 Mar 2025 21:38:27 +0100 Subject: Fix crash when Grok is enabled but no gpu_lister is available. --- src/lib/grok/util.cc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/lib') diff --git a/src/lib/grok/util.cc b/src/lib/grok/util.cc index 3cbc55678..51b9c1037 100644 --- a/src/lib/grok/util.cc +++ b/src/lib/grok/util.cc @@ -21,6 +21,7 @@ #include "util.h" #include "../config.h" +#include "../dcpomatic_log.h" #include #include @@ -37,17 +38,23 @@ get_gpu_names() auto binary = Config::instance()->grok().binary_location / "gpu_lister"; bp::ipstream stream; - bp::child child(binary, bp::std_out > stream); - string line; - vector gpu_names; - while (child.running() && std::getline(stream, line) && !line.empty()) { - gpu_names.push_back(line); - } + try { + bp::child child(binary, bp::std_out > stream); + + string line; + vector gpu_names; + while (child.running() && std::getline(stream, line) && !line.empty()) { + gpu_names.push_back(line); + } - child.wait(); + child.wait(); - return gpu_names; + return gpu_names; + } catch (std::exception& e) { + LOG_ERROR("Could not fetch GPU names: %1", e.what()); + return {}; + } } -- cgit v1.2.3