This is an automated email from the ASF dual-hosted git repository.

guangmingchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new 9f4947c4 fix: avoid SIGSEGV in read_proc_io during static 
initialization (#3184)
9f4947c4 is described below

commit 9f4947c4d1cfa7af8b3d0f6e3fc0aa6ea4abfb4f
Author: yujiasheng <[email protected]>
AuthorDate: Mon Dec 29 21:45:19 2025 +0800

    fix: avoid SIGSEGV in read_proc_io during static initialization (#3184)
    
    Signed-off-by: jiasheng.yu <[email protected]>
    Co-authored-by: jiasheng.yu <[email protected]>
---
 src/bvar/default_variables.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/bvar/default_variables.cpp b/src/bvar/default_variables.cpp
index 395d05e1..a84c3ab0 100644
--- a/src/bvar/default_variables.cpp
+++ b/src/bvar/default_variables.cpp
@@ -22,6 +22,8 @@
 #include <sys/resource.h>                  // getrusage
 #include <dirent.h>                        // dirent
 #include <iomanip>                         // setw
+#include <stdio.h>
+#include <errno.h>
 #if defined(__APPLE__)
 #include <libproc.h>
 #include <sys/resource.h>
@@ -430,7 +432,12 @@ static bool read_proc_io(ProcIO* s) {
 #if defined(OS_LINUX)
     butil::ScopedFILE fp("/proc/self/io", "r");
     if (NULL == fp) {
-        PLOG_ONCE(WARNING) << "Fail to open /proc/self/io";
+        static bool ever_printed_io_err = false;
+        if (!ever_printed_io_err) {
+            fprintf(stderr, "WARNING: Fail to open /proc/self/io, errno=%d. "
+                            "I/O related bvars will be unavailable.\n", errno);
+            ever_printed_io_err = true;
+        }
         return false;
     }
     errno = 0;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to