From ae3e41eb023e84327b927b9562813806428eaae1 Mon Sep 17 00:00:00 2001 From: ExPikaPaka Date: Thu, 1 Oct 2026 09:14:46 +0200 Subject: [PATCH] Add a regression test for a cyclic component reference Stores a painted cube, points its component back at the object that holds it and expects the load to fail. Without the bound the test does not finish: the work list grows until the process is killed. --- tests/libslic3r/test_3mf.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/libslic3r/test_3mf.cpp b/tests/libslic3r/test_3mf.cpp index 846caf5432..aed42e81b7 100644 --- a/tests/libslic3r/test_3mf.cpp +++ b/tests/libslic3r/test_3mf.cpp @@ -27,6 +27,7 @@ #include #include // for std::enable_if_t #include // for typeid +#include namespace Catch { template @@ -321,6 +322,30 @@ TEST_CASE("A project with a plate id below 1 fails to load", "[3mf][Regression]" REQUIRE_FALSE(loaded); } +TEST_CASE("A project whose components reference themselves fails to load", "[3mf][Regression]") +{ + ScopedTemporaryFile temp(".3mf"); + store_painted_cube(temp.string()); + + // Point the component back at the object that holds it. Expanding that reference used to push + // into the work list forever, growing it until the process ran out of memory. + REQUIRE(rewrite_3mf_entries(temp.string(), [](std::string& name, std::string& data) { + if (!boost::algorithm::ends_with(name, "3dmodel.model")) + return false; + std::smatch match; + if (!std::regex_search(data, match, std::regex("]*>\\s*