From 71be1c5f32df4b240924e156cd9fe1e4fef9eb8d Mon Sep 17 00:00:00 2001 From: not-matthias Date: Thu, 28 Aug 2025 14:21:38 +0200 Subject: [PATCH] fix(go): prevent running with valgrind --- .../{wall_time => helpers}/introspected_golang/go.sh | 7 +++++++ .../{wall_time => helpers}/introspected_golang/mod.rs | 0 src/run/runner/helpers/mod.rs | 1 + src/run/runner/valgrind/measure.rs | 9 ++++++--- src/run/runner/wall_time/executor.rs | 2 +- src/run/runner/wall_time/mod.rs | 1 - 6 files changed, 15 insertions(+), 5 deletions(-) rename src/run/runner/{wall_time => helpers}/introspected_golang/go.sh (87%) rename src/run/runner/{wall_time => helpers}/introspected_golang/mod.rs (100%) diff --git a/src/run/runner/wall_time/introspected_golang/go.sh b/src/run/runner/helpers/introspected_golang/go.sh similarity index 87% rename from src/run/runner/wall_time/introspected_golang/go.sh rename to src/run/runner/helpers/introspected_golang/go.sh index 54ebf9c9..d8a655f6 100755 --- a/src/run/runner/wall_time/introspected_golang/go.sh +++ b/src/run/runner/helpers/introspected_golang/go.sh @@ -11,6 +11,13 @@ debug_log() { debug_log "Called with arguments: $*" debug_log "Number of arguments: $#" + +# Currently only walltime is supported +if [ "${CODSPEED_RUNNER_MODE:-}" != "walltime" ]; then + echo "CRITICAL: Go benchmarks can only be run with the walltime instrument" + exit 1 +fi + # Find the real go binary, so that we don't end up in infinite recursion REAL_GO=$(which -a go | grep -v "$(realpath "$0")" | head -1) if [ -z "$REAL_GO" ]; then diff --git a/src/run/runner/wall_time/introspected_golang/mod.rs b/src/run/runner/helpers/introspected_golang/mod.rs similarity index 100% rename from src/run/runner/wall_time/introspected_golang/mod.rs rename to src/run/runner/helpers/introspected_golang/mod.rs diff --git a/src/run/runner/helpers/mod.rs b/src/run/runner/helpers/mod.rs index 41234673..0b8d507d 100644 --- a/src/run/runner/helpers/mod.rs +++ b/src/run/runner/helpers/mod.rs @@ -1,5 +1,6 @@ pub mod env; pub mod get_bench_command; +pub mod introspected_golang; pub mod profile_folder; pub mod run_command_with_log_pipe; pub mod setup; diff --git a/src/run/runner/valgrind/measure.rs b/src/run/runner/valgrind/measure.rs index d35c45ec..6c5a12ac 100644 --- a/src/run/runner/valgrind/measure.rs +++ b/src/run/runner/valgrind/measure.rs @@ -2,6 +2,7 @@ use crate::prelude::*; use crate::run::runner::RunnerMode; use crate::run::runner::helpers::env::get_base_injected_env; use crate::run::runner::helpers::get_bench_command::get_bench_command; +use crate::run::runner::helpers::introspected_golang; use crate::run::runner::helpers::run_command_with_log_pipe::run_command_with_log_pipe; use crate::run::runner::valgrind::helpers::ignored_objects_path::get_objects_path_to_ignore; use crate::run::runner::valgrind::helpers::introspected_nodejs::setup_introspected_nodejs; @@ -90,11 +91,13 @@ pub async fn measure( .env( "PATH", format!( - "{}:{}", + "{}:{}:{}", setup_introspected_nodejs() .map_err(|e| anyhow!("failed to setup NodeJS introspection. {}", e))? - .to_str() - .unwrap(), + .to_string_lossy(), + introspected_golang::setup_introspected_go() + .map_err(|e| anyhow!("failed to setup Go introspection. {}", e))? + .to_string_lossy(), env::var("PATH").unwrap_or_default(), ), ); diff --git a/src/run/runner/wall_time/executor.rs b/src/run/runner/wall_time/executor.rs index 3c61e4a4..c41c60e9 100644 --- a/src/run/runner/wall_time/executor.rs +++ b/src/run/runner/wall_time/executor.rs @@ -5,8 +5,8 @@ use crate::run::instruments::mongo_tracer::MongoTracer; use crate::run::runner::executor::Executor; use crate::run::runner::helpers::env::{get_base_injected_env, is_codspeed_debug_enabled}; use crate::run::runner::helpers::get_bench_command::get_bench_command; +use crate::run::runner::helpers::introspected_golang::setup_introspected_go; use crate::run::runner::helpers::run_command_with_log_pipe::run_command_with_log_pipe; -use crate::run::runner::wall_time::introspected_golang::setup_introspected_go; use crate::run::runner::{ExecutorName, RunData}; use crate::run::{check_system::SystemInfo, config::Config}; use async_trait::async_trait; diff --git a/src/run/runner/wall_time/mod.rs b/src/run/runner/wall_time/mod.rs index da8d3bdb..ca152f25 100644 --- a/src/run/runner/wall_time/mod.rs +++ b/src/run/runner/wall_time/mod.rs @@ -1,3 +1,2 @@ pub mod executor; -pub mod introspected_golang; pub mod perf;