From 8ce3972e21bfed8bb76109c4b315ae50b935122c Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 2 Mar 2023 14:10:16 -0800 Subject: [PATCH 1/2] client and server: increase p_features size from 1024 to 8192. 1024 wasn't enough for some CPUs. This caused some hosts to not get sse3 app versions, for example. Note: ideally we'd change this to std::string. But that would have disrupted the code that populates it (hostinfo_unix.cpp, hostinfo_win.cpp). Easier/safer to do it this way. --- client/hostinfo_unix.cpp | 6 +++--- db/boinc_db_types.h | 1 + lib/hostinfo.h | 2 +- sched/plan_class_spec.cpp | 10 ++++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/client/hostinfo_unix.cpp b/client/hostinfo_unix.cpp index 8342042e542..78fe2d29ef8 100644 --- a/client/hostinfo_unix.cpp +++ b/client/hostinfo_unix.cpp @@ -485,7 +485,7 @@ static void parse_meminfo_linux(HOST_INFO& host) { // See http://people.nl.linux.org/~hch/cpuinfo/ for some examples. // static void parse_cpuinfo_linux(HOST_INFO& host) { - char buf[1024], features[P_FEATURES_SIZE], model_buf[1024]; + char buf[P_FEATURES_SIZE], features[P_FEATURES_SIZE], model_buf[1024]; bool vendor_found=false, model_found=false; bool cache_found=false, features_found=false; bool model_hack=false, vendor_hack=false; @@ -762,7 +762,7 @@ void use_cpuid(HOST_INFO& host) { u_int cpu_id; char vendor[13]; int hasMMX, hasSSE, hasSSE2, hasSSE3, has3DNow, has3DNowExt, hasAVX; - char capabilities[256]; + char capabilities[P_FEATURES_SIZE]; hasMMX = hasSSE = hasSSE2 = hasSSE3 = has3DNow = has3DNowExt = hasAVX = 0; do_cpuid(0x0, p); @@ -1075,7 +1075,7 @@ static void get_cpu_info_haiku(HOST_INFO& host) { int32 found = 0; int32 i; - char buf[12]; + char buf[256]; for (i = 0; i < 32; i++) { if ((cpuInfo.eax_1.features & (1UL << i)) && kFeatures[i] != NULL) { diff --git a/db/boinc_db_types.h b/db/boinc_db_types.h index 41349c503a6..111f2e82b69 100644 --- a/db/boinc_db_types.h +++ b/db/boinc_db_types.h @@ -24,6 +24,7 @@ #include "opencl_boinc.h" #include "parse.h" #include "wslinfo.h" +#include "hostinfo.h" // Sizes of text buffers in memory, corresponding to database BLOBs. // The following is for regular blobs, 64KB diff --git a/lib/hostinfo.h b/lib/hostinfo.h index 55d64187ada..19859857cb4 100644 --- a/lib/hostinfo.h +++ b/lib/hostinfo.h @@ -50,7 +50,7 @@ const char file_redhatrelease[] = "/etc/redhat-release"; // if you add fields, update clear_host_info() -#define P_FEATURES_SIZE 1024 +#define P_FEATURES_SIZE 8192 class HOST_INFO { public: diff --git a/sched/plan_class_spec.cpp b/sched/plan_class_spec.cpp index 2c160dc5f15..fcbbb36a319 100644 --- a/sched/plan_class_spec.cpp +++ b/sched/plan_class_spec.cpp @@ -1286,12 +1286,14 @@ int main() { } for (unsigned int i=0; i Date: Sat, 4 Mar 2023 01:29:24 -0800 Subject: [PATCH 2/2] client, Unix: read full buf size when getting CPU features --- client/hostinfo_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/hostinfo_unix.cpp b/client/hostinfo_unix.cpp index 78fe2d29ef8..35b7b3f6dbd 100644 --- a/client/hostinfo_unix.cpp +++ b/client/hostinfo_unix.cpp @@ -527,7 +527,7 @@ static void parse_cpuinfo_linux(HOST_INFO& host) { host.m_cache=-1; safe_strcpy(features, ""); - while (fgets(buf, 1024, f)) { + while (fgets(buf, sizeof(buf), f)) { strip_whitespace(buf); if ( /* there might be conflicts if we dont #ifdef */