From b512d3bb3d8b2029101d58a29c5bd14da688bec2 Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Sun, 23 Aug 2026 20:00:51 -0500 Subject: [PATCH 1/3] Prevent telemetry crash in shell-less containers cpp_client_telemetry constructs a shared_ptr with pclose as its deleter even when popen fails. Chiseled images have no /bin/sh, so telemetry initialization calls pclose(nullptr) and terminates the process. Use unique_ptr ownership so a null pipe is not passed to pclose and telemetry can degrade gracefully. Files changed: - cmake/patches/cpp_client_telemetry/cpp_client_telemetry.patch: make the POSIX pipe owner null-safe. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d7d2f27a-7339-4585-ad02-9f89ce20ef40 --- .../cpp_client_telemetry/cpp_client_telemetry.patch | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmake/patches/cpp_client_telemetry/cpp_client_telemetry.patch b/cmake/patches/cpp_client_telemetry/cpp_client_telemetry.patch index 4a63bf2d79019..e2b092c130ff1 100644 --- a/cmake/patches/cpp_client_telemetry/cpp_client_telemetry.patch +++ b/cmake/patches/cpp_client_telemetry/cpp_client_telemetry.patch @@ -42,6 +42,19 @@ { LOG_ERROR("Unable to allocate memory to pack EventProperties"); +--- a/lib/pal/posix/sysinfo_sources.cpp ++++ b/lib/pal/posix/sysinfo_sources.cpp +@@ -114,7 +114,8 @@ + { + std::array buffer; + std::string result; +- std::shared_ptr pipe(popen(cmd, "r"), pclose); ++ auto close_pipe = [](FILE* file) { pclose(file); }; ++ std::unique_ptr pipe(popen(cmd, "r"), close_pipe); + if (!pipe) + { + // throw std::runtime_error("popen() failed!"); + --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -7,7 +7,7 @@ From 43b66347d1704ad561c85768fe9dc606ad889800 Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Sun, 23 Aug 2026 21:46:00 -0500 Subject: [PATCH 2/3] Align telemetry cleanup with upstream ownership fix Keep the existing shared ownership shape while making its custom deleter null-safe. This matches cpp_client_telemetry#1523 and avoids the function-pointer warning that occurred under the Linux warnings-as-errors build. Files changed: - cmake/patches/cpp_client_telemetry/cpp_client_telemetry.patch: guard pclose in the shared_ptr deleter. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d7d2f27a-7339-4585-ad02-9f89ce20ef40 --- .../cpp_client_telemetry/cpp_client_telemetry.patch | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/patches/cpp_client_telemetry/cpp_client_telemetry.patch b/cmake/patches/cpp_client_telemetry/cpp_client_telemetry.patch index e2b092c130ff1..27ee04039221d 100644 --- a/cmake/patches/cpp_client_telemetry/cpp_client_telemetry.patch +++ b/cmake/patches/cpp_client_telemetry/cpp_client_telemetry.patch @@ -44,13 +44,16 @@ --- a/lib/pal/posix/sysinfo_sources.cpp +++ b/lib/pal/posix/sysinfo_sources.cpp -@@ -114,7 +114,8 @@ +@@ -114,7 +114,11 @@ { std::array buffer; std::string result; - std::shared_ptr pipe(popen(cmd, "r"), pclose); -+ auto close_pipe = [](FILE* file) { pclose(file); }; -+ std::unique_ptr pipe(popen(cmd, "r"), close_pipe); ++ std::shared_ptr pipe(popen(cmd, "r"), [](FILE* file) { ++ if (file != nullptr) { ++ pclose(file); ++ } ++ }); if (!pipe) { // throw std::runtime_error("popen() failed!"); From 85e06789f8d280a90f4839b644285584636df8da Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Sun, 23 Aug 2026 22:34:48 -0500 Subject: [PATCH 3/3] Use unique ownership in telemetry compatibility fix The pipe returned by popen has one owner. Matching the upstream unique_ptr fix makes that lifetime explicit and naturally avoids pclose for a null handle. Files changed:`n- cmake/patches/cpp_client_telemetry/cpp_client_telemetry.patch: use the upstream lambda-deleter unique_ptr. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>`nCopilot-Session: d7d2f27a-7339-4585-ad02-9f89ce20ef40 --- .../cpp_client_telemetry/cpp_client_telemetry.patch | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cmake/patches/cpp_client_telemetry/cpp_client_telemetry.patch b/cmake/patches/cpp_client_telemetry/cpp_client_telemetry.patch index 27ee04039221d..e2b092c130ff1 100644 --- a/cmake/patches/cpp_client_telemetry/cpp_client_telemetry.patch +++ b/cmake/patches/cpp_client_telemetry/cpp_client_telemetry.patch @@ -44,16 +44,13 @@ --- a/lib/pal/posix/sysinfo_sources.cpp +++ b/lib/pal/posix/sysinfo_sources.cpp -@@ -114,7 +114,11 @@ +@@ -114,7 +114,8 @@ { std::array buffer; std::string result; - std::shared_ptr pipe(popen(cmd, "r"), pclose); -+ std::shared_ptr pipe(popen(cmd, "r"), [](FILE* file) { -+ if (file != nullptr) { -+ pclose(file); -+ } -+ }); ++ auto close_pipe = [](FILE* file) { pclose(file); }; ++ std::unique_ptr pipe(popen(cmd, "r"), close_pipe); if (!pipe) { // throw std::runtime_error("popen() failed!");