From ffd29e5a0e92c1c9fe4015187e305727cbd9effd Mon Sep 17 00:00:00 2001 From: JanqeD Date: Tue, 30 Jun 2026 11:59:42 -0400 Subject: [PATCH 1/2] fix(emboss): raise worker thread stack to 256MB to survive CGAL exact-arithmetic text-cut The Emboss "On Surface" path calls CGAL corefine, which falls back to exact GMP rational arithmetic on near-degenerate inputs and recurses deeply. The 4MB stack (Snapmaker 2.3.4) overflows the guard page -> SIGBUS in __gmpn_*/__gmpz_gcd on macOS arm64. Even the 16MB upstream bump (PR #13772) still overflows on real models (verified: a clean 214k-tri cooler consumed the full 16MB stack). Reserve 256MB; thread-stack pages are committed lazily so idle workers cost address space, not RAM. --- src/libslic3r/Thread.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/Thread.hpp b/src/libslic3r/Thread.hpp index f9dc07456cd..a7edae734b7 100644 --- a/src/libslic3r/Thread.hpp +++ b/src/libslic3r/Thread.hpp @@ -50,7 +50,12 @@ inline boost::thread create_thread(boost::thread::attributes &attrs, Fn &&fn) // threads of the thread pool: allocate 4MB on a 64bit system, allocate 2MB // on a 32bit system by default. - attrs.set_stack_size((sizeof(void*) == 4) ? (2048 * 1024) : (4096 * 1024)); + // Orca: the Emboss "On Surface" text-cut calls CGAL Polygon_mesh_processing::corefine, + // which falls back to exact rational (GMP/mpq) arithmetic on near-degenerate inputs and + // recurses deeply. The old 4 MB stack (and even the 16 MB upstream bump) overflows into the + // stack guard page -> EXC_BAD_ACCESS/SIGBUS in __gmpn_*/__gmpz_gcd on macOS. Reserve 256 MB; + // macOS/Linux commit thread-stack pages lazily, so idle workers cost address space, not RAM. + attrs.set_stack_size(256ull * 1024 * 1024); return boost::thread{attrs, std::forward(fn)}; } From b05204cd84786fa351da5b664f5d9fe730a1758c Mon Sep 17 00:00:00 2001 From: JanqeD Date: Tue, 30 Jun 2026 22:01:07 -0400 Subject: [PATCH 2/2] fix(emboss): bump CGAL 5.4 -> 5.6.3 to fix corefine exact-arithmetic heap over-read The Emboss 'On Surface' cut_surface path crashes on macOS/arm64 with EXC_BAD_ACCESS inside CGAL corefinement's exact (Epeck) constrained triangulation (insert_constraint -> Compare_along_axis -> __gmpz_mul reads past a heap buffer). Snapmaker 2.3.4 pins CGAL 5.4 (2022); mainline OrcaSlicer already uses 5.6.3, which is API-compatible with this Emboss/CutSurface code and carries ~1.5y of PMP/corefinement fixes. Drop the 5.4-only clang19 patch (does not apply to 5.6.3). --- deps/CGAL/CGAL.cmake | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/deps/CGAL/CGAL.cmake b/deps/CGAL/CGAL.cmake index ff8ea1f74c6..31731b7283f 100644 --- a/deps/CGAL/CGAL.cmake +++ b/deps/CGAL/CGAL.cmake @@ -5,11 +5,14 @@ endif () Snapmaker_Orca_add_cmake_project( CGAL # GIT_REPOSITORY https://github.com/CGAL/cgal.git - # GIT_TAG bec70a6d52d8aacb0b3d82a7b4edc3caa899184b # releases/CGAL-5.0 - # For whatever reason, this keeps downloading forever (repeats downloads if finished) - URL https://github.com/CGAL/cgal/archive/refs/tags/v5.4.zip - URL_HASH SHA256=d7605e0a5a5ca17da7547592f6f6e4a59430a0bc861948974254d0de43eab4c0 - PATCH_COMMAND git apply ${CGAL_DIRECTORY_FLAG} --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/0001-clang19.patch + # GIT_TAG 3654f780ae0c64675cabaef0e5ddaf904c48b4b7 # releases/CGAL-5.6.3 + # Bumped CGAL 5.4 -> 5.6.3 (matching mainline OrcaSlicer) to fix the Emboss + # "On Surface" cut_surface crash: a heap over-read inside CGAL's corefinement + # exact-arithmetic (Epeck) constrained triangulation on macOS/arm64. 5.6.3 is + # API-compatible with this Emboss/CutSurface code (mainline ships it). The + # 5.4-only 0001-clang19.patch is dropped (does not apply to 5.6.3). + URL https://github.com/CGAL/cgal/releases/download/v5.6.3/CGAL-5.6.3.zip + URL_HASH SHA256=5d577acb4a9918ccb960491482da7a3838f8d363aff47e14d703f19fd84733d4 DEPENDS dep_Boost dep_GMP dep_MPFR )