diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 48583dc2b3d05..b7d0749722d86 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -40,7 +40,7 @@ set(Seastar_API_LEVEL 6 CACHE STRING "" FORCE) set(Seastar_CXX_FLAGS -Wno-error) fetch_dep(seastar REPO https://github.com/redpanda-data/seastar.git - TAG v23.3.x + TAG v24.1.x PATCH_COMMAND sed -i "s/add_subdirectory (tests/# add_subdirectory (tests/g" CMakeLists.txt) fetch_dep(avro diff --git a/src/v/wasm/tests/wasm_transform_test.cc b/src/v/wasm/tests/wasm_transform_test.cc index ae76ac359ea5a..85ce8e58ca990 100644 --- a/src/v/wasm/tests/wasm_transform_test.cc +++ b/src/v/wasm/tests/wasm_transform_test.cc @@ -11,10 +11,10 @@ #include "bytes/bytes.h" #include "pandaproxy/schema_registry/types.h" -#include "serde/rw/rw.h" #include "wasm/errc.h" #include "wasm/tests/wasm_fixture.h" +#include #include #include @@ -134,3 +134,20 @@ TEST_F(WasmTestFixture, LogsAreEmitted) { expected.append(reinterpret_cast(bytes.data()), bytes.size()); EXPECT_THAT(log_lines(), ElementsAre(expected)); } + +TEST_F(WasmTestFixture, WorksWithCpuProfiler) { + bool original_enabled = ss::engine().get_cpu_profiler_enabled(); + std::chrono::nanoseconds original_period + = ss::engine().get_cpu_profiler_period(); + ss::engine().set_cpu_profiler_enabled(true); + ss::engine().set_cpu_profiler_period(100us); + load_wasm("dynamic.wasm"); + EXPECT_THROW(execute_command("loop", 0), wasm::wasm_exception); + ss::engine().set_cpu_profiler_enabled(original_enabled); + ss::engine().set_cpu_profiler_period(original_period); + std::vector traces; + ss::engine().profiler_results(traces); + for (const auto& t : traces) { + std::cout << t.user_backtrace << "\n"; + } +} diff --git a/src/v/wasm/wasmtime.cc b/src/v/wasm/wasmtime.cc index e8fc7c70d8800..e7291252530dd 100644 --- a/src/v/wasm/wasmtime.cc +++ b/src/v/wasm/wasmtime.cc @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -599,7 +600,13 @@ class wasmtime_engine : public engine { // Poll the call future to completion, yielding to the scheduler when // the future yields. auto start = ss::steady_clock_type::now(); + // Disable profiling backtraces inside the VM - at the time of writing + // backtraces lead to segfaults causing deadlock in Seastar's signal + // handlers. + auto _ = ss::internal::scoped_disable_profile_temporarily(); while (!wasmtime_call_future_poll(fut.get())) { + // Re-enable stacktraces before we yield control to the scheduler. + ss::internal::profiler_drop_stacktraces(false); auto end = ss::steady_clock_type::now(); _probe.increment_cpu_time(end - start); if (_pending_host_function) { @@ -609,6 +616,8 @@ class wasmtime_engine : public engine { co_await ss::coroutine::maybe_yield(); } start = ss::steady_clock_type::now(); + // Disable stacktraces as we enter back into Wasmtime + ss::internal::profiler_drop_stacktraces(true); } auto end = ss::steady_clock_type::now(); _probe.increment_cpu_time(end - start);