Skip to content

Commit

Permalink
#15290: Fix UAF issue with Singleton destruction order
Browse files Browse the repository at this point in the history
- Decouple MeshDevice destruction from SystemMesh destruction.
- Refactor SystemMesh to encapsulate internals in pImpl class.
- Added a new test case for SystemMesh tear down with static mesh in the distributed tests.
  • Loading branch information
cfjchu committed Dec 5, 2024
1 parent 0a73de0 commit 151cdb8
Show file tree
Hide file tree
Showing 4 changed files with 265 additions and 186 deletions.
6 changes: 5 additions & 1 deletion tests/ttnn/distributed/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
add_executable(test_distributed test_distributed.cpp)
add_executable(
test_distributed
test_distributed.cpp
test_distributed_atexit.cpp
)

# Set up properties for the target
setup_ttnn_test_target(test_distributed)
Expand Down
25 changes: 25 additions & 0 deletions tests/ttnn/distributed/test_distributed_atexit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.
//
// SPDX-License-Identifier: Apache-2.0

#include <gtest/gtest.h>

#include <cstddef>
#include <ttnn/core.hpp>
#include <ttnn/distributed/api.hpp>

namespace ttnn::distributed::test {

// Simplified test without fixture, and mesh variable moved inside test
TEST(DistributedTestStandalone, TestSystemMeshTearDownWithoutClose) {
static std::shared_ptr<ttnn::MeshDevice> mesh;
auto& sys = tt::tt_metal::distributed::SystemMesh::instance();
mesh = ttnn::distributed::open_mesh_device(
{2, 4}, DEFAULT_L1_SMALL_SIZE, DEFAULT_TRACE_REGION_SIZE, 1, tt::tt_metal::DispatchCoreType::WORKER);

auto [rows, cols] = sys.get_shape();
EXPECT_GT(rows, 0);
EXPECT_GT(cols, 0);
}

} // namespace ttnn::distributed::test
Loading

0 comments on commit 151cdb8

Please sign in to comment.