From b8674165104f7766c178818b28f86096a1725478 Mon Sep 17 00:00:00 2001 From: Jan Kleinert Date: Fri, 13 Nov 2026 15:39:02 +0100 Subject: [PATCH 1/6] debugging diagnostics --- src/geom/geom_extras.hpp | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/geom/geom_extras.hpp b/src/geom/geom_extras.hpp index aea0553..4739689 100644 --- a/src/geom/geom_extras.hpp +++ b/src/geom/geom_extras.hpp @@ -79,4 +79,67 @@ inline void register_geom_extras(grunk::plugin_namespace& ns) ); ns.modify_type("Geom_Curve").with_std_vector>(); + + // TEMP DIAGNOSTIC (remove once the macOS-only occt.Geom_Curve.as_vec(...) + // failure is root-caused - see grunk-geoml's own DESIGN.md/CI issue this is + // chasing): with_std_vector() above reproduces the real + // bug on macOS even for curves built entirely via occt.* calls (same dylib + // as this registration) - ruling out cross-plugin origin as the cause. A + // hand-rolled replica of the exact same cast_to_element/convert_one logic, + // registered as a plain NAMESPACE function (no usertype, no sol::overload), + // works fine on macOS (grunk-geoml's own debug_as_vec3). The two structural + // differences between that working replica and this real, broken + // with_std_vector()-produced as_vec are (a) usertype member-function + // registration (add_member_function, looked up via `occt.Geom_Curve.as_vec`) + // vs a plain namespace function, and (b) sol::overload(from_table, + // from_varargs) - two candidates - vs one plain lambda. The three probes + // below isolate each factor and their combination, duplicating + // cast_to_element/convert_one inline (not worth factoring out for + // throwaway diagnostic code): + // debug_member_novoverload - member function, no overload (tests (a) alone) + // debug_namespace_overload - namespace function, with overload (tests (b) alone) + // debug_member_overload - both together (expected to fail, reproducing + // the real as_vec exactly, as a sanity check + // that this hand-rolled copy is equivalent) + { + // cast_to_element is built fresh from whichever lua_State the call itself + // carries (va.lua_state()/t.lua_state()) rather than once at registration + // time - plugin_namespace has no lua_state() accessor of its own, and this + // is throwaway diagnostic code, not worth plumbing one through. + auto convert_one = [](auto const& v) -> opencascade::handle { + std::string const ud_name = "Geom_Curve"; + if (v.get_type() != sol::type::userdata) { + throw std::runtime_error("Cannot create std::vector. The values cannot be converted to the expected usertype \"" + ud_name + "\"."); + } + sol::state_view lua(v.lua_state()); + sol::protected_function cast_to_element = sol::make_object( + lua, [](opencascade::handle x) -> opencascade::handle { return x; } + ); + sol::protected_function_result res = cast_to_element(v); + if (!res.valid()) { + throw std::runtime_error("Cannot create std::vector. The values cannot be converted to the expected usertype \"" + ud_name + "\"."); + } + return res.get>(); + }; + auto from_varargs = [convert_one](sol::variadic_args va) { + std::vector> ret; + ret.reserve(va.size()); + for (auto const& v : va) { + ret.push_back(convert_one(v)); + } + return ret; + }; + auto from_table = [convert_one](sol::table t) { + std::vector> ret; + ret.reserve(t.size()); + for (auto const& kv : t) { + ret.push_back(convert_one(kv.second)); + } + return ret; + }; + + ns.modify_type("Geom_Curve").add_member_function("debug_member_novoverload", from_varargs); + ns.register_function("debug_namespace_overload", sol::overload(from_table, from_varargs)); + ns.modify_type("Geom_Curve").add_member_function("debug_member_overload", sol::overload(from_table, from_varargs)); + } } From d61db8fc1b99c7995b6c1287e6d2ff08f9ecd392 Mon Sep 17 00:00:00 2001 From: Jan Kleinert Date: Sat, 14 Nov 2026 10:55:23 +0100 Subject: [PATCH 2/6] next diagnostics iteration --- src/geom/geom_extras.hpp | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/geom/geom_extras.hpp b/src/geom/geom_extras.hpp index 4739689..4d9d6e3 100644 --- a/src/geom/geom_extras.hpp +++ b/src/geom/geom_extras.hpp @@ -142,4 +142,56 @@ inline void register_geom_extras(grunk::plugin_namespace& ns) ns.register_function("debug_namespace_overload", sol::overload(from_table, from_varargs)); ns.modify_type("Geom_Curve").add_member_function("debug_member_overload", sol::overload(from_table, from_varargs)); } + + // TEMP DIAGNOSTIC, round 2 (remove alongside the probes above): all three + // probes above - including debug_member_overload, structurally identical to + // with_std_vector's own add_member_function("as_vec", sol::overload(...)) + // call - PASSED on macOS, while the real occt.Geom_Curve.as_vec(...) still + // fails on the exact same curves (see debug_as_vec_variants.grr.yml's own + // CI results). The one remaining difference: the real with_std_vector() + // builds cast_to_element ONCE, at *registration* time (plugin-load time), + // via `sol::state_view lua(ut.lua_state())` - a single sol::protected_function + // captured by value into convert_one's closure and reused for the lifetime + // of the process. The probes above instead rebuild cast_to_element FRESH on + // *every call* (plugin_namespace has no lua_state() accessor of its own, so + // this was a pragmatic workaround, not a deliberate design choice) - this + // probe removes that difference, building cast_to_element once via the + // usertype_proxy's own `ut.lua_state()` (public member, same accessor + // with_std_vector itself uses), to test whether a persistent, + // registration-time-captured closure is what actually breaks on macOS. + { + auto proxy = ns.modify_type("Geom_Curve"); + std::string const ud_name = "Geom_Curve"; + sol::state_view lua(proxy.ut.lua_state()); + sol::protected_function cast_to_element = sol::make_object( + lua, [](opencascade::handle x) -> opencascade::handle { return x; } + ); + auto convert_one = [ud_name, cast_to_element](auto const& v) -> opencascade::handle { + if (v.get_type() != sol::type::userdata) { + throw std::runtime_error("Cannot create std::vector. The values cannot be converted to the expected usertype \"" + ud_name + "\"."); + } + sol::protected_function_result res = cast_to_element(v); + if (!res.valid()) { + throw std::runtime_error("Cannot create std::vector. The values cannot be converted to the expected usertype \"" + ud_name + "\"."); + } + return res.get>(); + }; + auto from_varargs = [convert_one](sol::variadic_args va) { + std::vector> ret; + ret.reserve(va.size()); + for (auto const& v : va) { + ret.push_back(convert_one(v)); + } + return ret; + }; + auto from_table = [convert_one](sol::table t) { + std::vector> ret; + ret.reserve(t.size()); + for (auto const& kv : t) { + ret.push_back(convert_one(kv.second)); + } + return ret; + }; + ns.modify_type("Geom_Curve").add_member_function("debug_member_overload_persistent_cast", sol::overload(from_table, from_varargs)); + } } From 32c320f5cc1d7f72e11526ef757a4d1fb1f244ca Mon Sep 17 00:00:00 2001 From: Jan Kleinert Date: Mon, 16 Nov 2026 12:18:38 +0100 Subject: [PATCH 3/6] more diagnostics --- pixi.lock | 10 +++++----- pixi.toml | 4 ++-- scripts/install_grunk.cmake | 7 ++++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pixi.lock b/pixi.lock index c1d7ced..9af9abe 100644 --- a/pixi.lock +++ b/pixi.lock @@ -71,7 +71,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/ca-certificates-2026.7.22-hbd8a1cb_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.14-9_cp314.conda - conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2026c-h151e31d_0.conda - - pypi: git+https://github.com/grunk-dev/grunk.git?rev=6bf642412c7d501101585a41370050386551f759#6bf642412c7d501101585a41370050386551f759 + - pypi: git+https://github.com/grunk-dev/grunk.git?rev=f72d47c3a4756a284e03766c1f1f362a7f10926c#f72d47c3a4756a284e03766c1f1f362a7f10926c - pypi: https://files.pythonhosted.org/packages/1d/fc/716c1e62e512ef1c160e7984a73a5fc7df45166f2ff3f254e71c58076f7c/libclang-18.1.1-py2.py3-none-manylinux2010_x86_64.whl - pypi: https://files.pythonhosted.org/packages/88/f9/16491d7ed2a919954993e48aa941b200f38040928474c9e85ea9e64222c3/pyyaml-6.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl default: @@ -179,7 +179,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/tomli-2.4.1-pyhcf101f3_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/typing_extensions-4.16.0-pyhcf101f3_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2026c-h151e31d_0.conda - - pypi: git+https://github.com/grunk-dev/grunk.git?rev=6bf642412c7d501101585a41370050386551f759#6bf642412c7d501101585a41370050386551f759 + - pypi: git+https://github.com/grunk-dev/grunk.git?rev=f72d47c3a4756a284e03766c1f1f362a7f10926c#f72d47c3a4756a284e03766c1f1f362a7f10926c - pypi: https://files.pythonhosted.org/packages/1d/fc/716c1e62e512ef1c160e7984a73a5fc7df45166f2ff3f254e71c58076f7c/libclang-18.1.1-py2.py3-none-manylinux2010_x86_64.whl - pypi: https://files.pythonhosted.org/packages/88/f9/16491d7ed2a919954993e48aa941b200f38040928474c9e85ea9e64222c3/pyyaml-6.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl osx-64: @@ -258,7 +258,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/osx-64/tk-8.6.13-ha6c374e_4.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/yaml-cpp-0.8.0-h2fb4741_1.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/zstd-1.5.7-hbc1a06c_7.conda - - pypi: git+https://github.com/grunk-dev/grunk.git?rev=6bf642412c7d501101585a41370050386551f759#6bf642412c7d501101585a41370050386551f759 + - pypi: git+https://github.com/grunk-dev/grunk.git?rev=f72d47c3a4756a284e03766c1f1f362a7f10926c#f72d47c3a4756a284e03766c1f1f362a7f10926c - pypi: https://files.pythonhosted.org/packages/9d/8c/f4bd7f6465179953d3ac9bc44ac1a8a3e6122cf8ada906b4f96c60172d43/pyyaml-6.0.3-cp314-cp314-macosx_10_13_x86_64.whl - pypi: https://files.pythonhosted.org/packages/e2/e5/fc61bbded91a8830ccce94c5294ecd6e88e496cc85f6704bf350c0634b70/libclang-18.1.1-py2.py3-none-macosx_10_9_x86_64.whl win-64: @@ -335,7 +335,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/win-64/yaml-cpp-0.8.0-h5112557_1.conda - conda: https://conda.anaconda.org/conda-forge/win-64/zlib-1.3.2-hfd05255_3.conda - conda: https://conda.anaconda.org/conda-forge/win-64/zstd-1.5.7-h534d264_7.conda - - pypi: git+https://github.com/grunk-dev/grunk.git?rev=6bf642412c7d501101585a41370050386551f759#6bf642412c7d501101585a41370050386551f759 + - pypi: git+https://github.com/grunk-dev/grunk.git?rev=f72d47c3a4756a284e03766c1f1f362a7f10926c#f72d47c3a4756a284e03766c1f1f362a7f10926c - pypi: https://files.pythonhosted.org/packages/0b/2d/3f480b1e1d31eb3d6de5e3ef641954e5c67430d5ac93b7fa7e07589576c7/libclang-18.1.1-py2.py3-none-win_amd64.whl - pypi: https://files.pythonhosted.org/packages/23/20/bb6982b26a40bb43951265ba29d4c246ef0ff59c9fdcdf0ed04e0687de4d/pyyaml-6.0.3-cp314-cp314-win_amd64.whl tools: @@ -3673,7 +3673,7 @@ packages: - zstd >=1.5.7,<1.6.0a0 size: 387535 timestamp: 1786599623274 -- pypi: git+https://github.com/grunk-dev/grunk.git?rev=6bf642412c7d501101585a41370050386551f759#6bf642412c7d501101585a41370050386551f759 +- pypi: git+https://github.com/grunk-dev/grunk.git?rev=f72d47c3a4756a284e03766c1f1f362a7f10926c#f72d47c3a4756a284e03766c1f1f362a7f10926c name: grunk version: 0.5.0 requires_dist: diff --git a/pixi.toml b/pixi.toml index ee28e3d..12d0123 100644 --- a/pixi.toml +++ b/pixi.toml @@ -47,7 +47,7 @@ pytest = "*" # console script and its libclang/pyyaml dependencies come along transitively with # this same pin, since grunk.codegen (grunk/python/grunk/codegen/) now lives in the # grunk package itself rather than a local codegen/generate.py copy here. -grunk = { git = "https://github.com/grunk-dev/grunk.git", rev = "6bf642412c7d501101585a41370050386551f759" } +grunk = { git = "https://github.com/grunk-dev/grunk.git", rev = "f72d47c3a4756a284e03766c1f1f362a7f10926c" } # Stock OCCT - only pulled in by the `default` environment (see [environments]). # Kept out of [dependencies] specifically so the `ad` environment (adOCCT instead, @@ -111,7 +111,7 @@ freetype = "*" # libclang/pyyaml that comes along transitively with grunk's own default-feature # copy of this pin for that reason. [feature.ad.pypi-dependencies] -grunk = { git = "https://github.com/grunk-dev/grunk.git", rev = "6bf642412c7d501101585a41370050386551f759" } +grunk = { git = "https://github.com/grunk-dev/grunk.git", rev = "f72d47c3a4756a284e03766c1f1f362a7f10926c" } [feature.ad.activation.env] # Needed for the same reason [target.linux-64.activation.env]'s own copy is - cmake's diff --git a/scripts/install_grunk.cmake b/scripts/install_grunk.cmake index 6f2ee48..3cd24be 100644 --- a/scripts/install_grunk.cmake +++ b/scripts/install_grunk.cmake @@ -124,7 +124,12 @@ endif() # bug. Pure python/grunk/codegen/generate.py change - no effect on already- # generated generated/*.cpp or the runtime C++ libraries, only on the next # `generate_code` run. -set(GRUNK_REV "6bf642412c7d501101585a41370050386551f759") +# TEMP DIAGNOSTIC (revert to 6bf642412c7d501101585a41370050386551f759 - or +# whatever grunk main is at by then - once the macOS-only occt.Geom_Curve.as_vec +# failure is root-caused): f72d47c is grunk's with_vector_diagnostics branch, +# 6bf6424 plus stderr instrumentation inside with_std_vector() itself, so the +# next macOS CI run reports which throw branch fires and sol2's own error text. +set(GRUNK_REV "f72d47c3a4756a284e03766c1f1f362a7f10926c") get_filename_component(PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) set(GRUNK_PREFIX "${PROJECT_ROOT}/.deps/${GRUNK_INSTALL_NAME}") From eeec065e52baf0a257ea22161960e356b0079f03 Mon Sep 17 00:00:00 2001 From: Jan Kleinert Date: Mon, 23 Nov 2026 13:45:13 +0100 Subject: [PATCH 4/6] bump grunk --- pixi.lock | 10 +++++----- pixi.toml | 4 ++-- scripts/install_grunk.cmake | 15 +++++++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/pixi.lock b/pixi.lock index 9af9abe..db9c581 100644 --- a/pixi.lock +++ b/pixi.lock @@ -71,7 +71,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/ca-certificates-2026.7.22-hbd8a1cb_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.14-9_cp314.conda - conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2026c-h151e31d_0.conda - - pypi: git+https://github.com/grunk-dev/grunk.git?rev=f72d47c3a4756a284e03766c1f1f362a7f10926c#f72d47c3a4756a284e03766c1f1f362a7f10926c + - pypi: git+https://github.com/grunk-dev/grunk.git?rev=6b08b0e0dec3d66b56a2e7eaa415ebdd67b7a9dc#6b08b0e0dec3d66b56a2e7eaa415ebdd67b7a9dc - pypi: https://files.pythonhosted.org/packages/1d/fc/716c1e62e512ef1c160e7984a73a5fc7df45166f2ff3f254e71c58076f7c/libclang-18.1.1-py2.py3-none-manylinux2010_x86_64.whl - pypi: https://files.pythonhosted.org/packages/88/f9/16491d7ed2a919954993e48aa941b200f38040928474c9e85ea9e64222c3/pyyaml-6.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl default: @@ -179,7 +179,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/tomli-2.4.1-pyhcf101f3_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/typing_extensions-4.16.0-pyhcf101f3_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2026c-h151e31d_0.conda - - pypi: git+https://github.com/grunk-dev/grunk.git?rev=f72d47c3a4756a284e03766c1f1f362a7f10926c#f72d47c3a4756a284e03766c1f1f362a7f10926c + - pypi: git+https://github.com/grunk-dev/grunk.git?rev=6b08b0e0dec3d66b56a2e7eaa415ebdd67b7a9dc#6b08b0e0dec3d66b56a2e7eaa415ebdd67b7a9dc - pypi: https://files.pythonhosted.org/packages/1d/fc/716c1e62e512ef1c160e7984a73a5fc7df45166f2ff3f254e71c58076f7c/libclang-18.1.1-py2.py3-none-manylinux2010_x86_64.whl - pypi: https://files.pythonhosted.org/packages/88/f9/16491d7ed2a919954993e48aa941b200f38040928474c9e85ea9e64222c3/pyyaml-6.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl osx-64: @@ -258,7 +258,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/osx-64/tk-8.6.13-ha6c374e_4.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/yaml-cpp-0.8.0-h2fb4741_1.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/zstd-1.5.7-hbc1a06c_7.conda - - pypi: git+https://github.com/grunk-dev/grunk.git?rev=f72d47c3a4756a284e03766c1f1f362a7f10926c#f72d47c3a4756a284e03766c1f1f362a7f10926c + - pypi: git+https://github.com/grunk-dev/grunk.git?rev=6b08b0e0dec3d66b56a2e7eaa415ebdd67b7a9dc#6b08b0e0dec3d66b56a2e7eaa415ebdd67b7a9dc - pypi: https://files.pythonhosted.org/packages/9d/8c/f4bd7f6465179953d3ac9bc44ac1a8a3e6122cf8ada906b4f96c60172d43/pyyaml-6.0.3-cp314-cp314-macosx_10_13_x86_64.whl - pypi: https://files.pythonhosted.org/packages/e2/e5/fc61bbded91a8830ccce94c5294ecd6e88e496cc85f6704bf350c0634b70/libclang-18.1.1-py2.py3-none-macosx_10_9_x86_64.whl win-64: @@ -335,7 +335,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/win-64/yaml-cpp-0.8.0-h5112557_1.conda - conda: https://conda.anaconda.org/conda-forge/win-64/zlib-1.3.2-hfd05255_3.conda - conda: https://conda.anaconda.org/conda-forge/win-64/zstd-1.5.7-h534d264_7.conda - - pypi: git+https://github.com/grunk-dev/grunk.git?rev=f72d47c3a4756a284e03766c1f1f362a7f10926c#f72d47c3a4756a284e03766c1f1f362a7f10926c + - pypi: git+https://github.com/grunk-dev/grunk.git?rev=6b08b0e0dec3d66b56a2e7eaa415ebdd67b7a9dc#6b08b0e0dec3d66b56a2e7eaa415ebdd67b7a9dc - pypi: https://files.pythonhosted.org/packages/0b/2d/3f480b1e1d31eb3d6de5e3ef641954e5c67430d5ac93b7fa7e07589576c7/libclang-18.1.1-py2.py3-none-win_amd64.whl - pypi: https://files.pythonhosted.org/packages/23/20/bb6982b26a40bb43951265ba29d4c246ef0ff59c9fdcdf0ed04e0687de4d/pyyaml-6.0.3-cp314-cp314-win_amd64.whl tools: @@ -3673,7 +3673,7 @@ packages: - zstd >=1.5.7,<1.6.0a0 size: 387535 timestamp: 1786599623274 -- pypi: git+https://github.com/grunk-dev/grunk.git?rev=f72d47c3a4756a284e03766c1f1f362a7f10926c#f72d47c3a4756a284e03766c1f1f362a7f10926c +- pypi: git+https://github.com/grunk-dev/grunk.git?rev=6b08b0e0dec3d66b56a2e7eaa415ebdd67b7a9dc#6b08b0e0dec3d66b56a2e7eaa415ebdd67b7a9dc name: grunk version: 0.5.0 requires_dist: diff --git a/pixi.toml b/pixi.toml index 12d0123..11d7536 100644 --- a/pixi.toml +++ b/pixi.toml @@ -47,7 +47,7 @@ pytest = "*" # console script and its libclang/pyyaml dependencies come along transitively with # this same pin, since grunk.codegen (grunk/python/grunk/codegen/) now lives in the # grunk package itself rather than a local codegen/generate.py copy here. -grunk = { git = "https://github.com/grunk-dev/grunk.git", rev = "f72d47c3a4756a284e03766c1f1f362a7f10926c" } +grunk = { git = "https://github.com/grunk-dev/grunk.git", rev = "6b08b0e0dec3d66b56a2e7eaa415ebdd67b7a9dc" } # Stock OCCT - only pulled in by the `default` environment (see [environments]). # Kept out of [dependencies] specifically so the `ad` environment (adOCCT instead, @@ -111,7 +111,7 @@ freetype = "*" # libclang/pyyaml that comes along transitively with grunk's own default-feature # copy of this pin for that reason. [feature.ad.pypi-dependencies] -grunk = { git = "https://github.com/grunk-dev/grunk.git", rev = "f72d47c3a4756a284e03766c1f1f362a7f10926c" } +grunk = { git = "https://github.com/grunk-dev/grunk.git", rev = "6b08b0e0dec3d66b56a2e7eaa415ebdd67b7a9dc" } [feature.ad.activation.env] # Needed for the same reason [target.linux-64.activation.env]'s own copy is - cmake's diff --git a/scripts/install_grunk.cmake b/scripts/install_grunk.cmake index 3cd24be..5ef9e70 100644 --- a/scripts/install_grunk.cmake +++ b/scripts/install_grunk.cmake @@ -124,12 +124,15 @@ endif() # bug. Pure python/grunk/codegen/generate.py change - no effect on already- # generated generated/*.cpp or the runtime C++ libraries, only on the next # `generate_code` run. -# TEMP DIAGNOSTIC (revert to 6bf642412c7d501101585a41370050386551f759 - or -# whatever grunk main is at by then - once the macOS-only occt.Geom_Curve.as_vec -# failure is root-caused): f72d47c is grunk's with_vector_diagnostics branch, -# 6bf6424 plus stderr instrumentation inside with_std_vector() itself, so the -# next macOS CI run reports which throw branch fires and sol2's own error text. -set(GRUNK_REV "f72d47c3a4756a284e03766c1f1f362a7f10926c") +# Bumped again 2026-11-17 to 6b08b0e0dec3d66b56a2e7eaa415ebdd67b7a9dc (grunk's +# own main, post PR grunk-dev/grunk#317 merge, fixing grunk-dev/grunk#300) - +# with_std_vector()'s element cast is now a named function template instead of +# a lambda. Under Clang, sol2's __PRETTY_FUNCTION__-derived metatable name for +# that lambda was identical across instantiations, so Handle(Geom_Curve)'s +# as_vec silently reused gp_Pnt's cast and rejected every argument - the +# macOS-only occt.Geom_Curve.as_vec failure. Runtime header change: requires +# a rebuild, not just a regenerate. +set(GRUNK_REV "6b08b0e0dec3d66b56a2e7eaa415ebdd67b7a9dc") get_filename_component(PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) set(GRUNK_PREFIX "${PROJECT_ROOT}/.deps/${GRUNK_INSTALL_NAME}") From 7530c40127ef25a9c7c621282e02654c27b65515 Mon Sep 17 00:00:00 2001 From: Jan Kleinert Date: Mon, 23 Nov 2026 15:09:50 +0100 Subject: [PATCH 5/6] revert dagnostic probe functions --- src/geom/geom_extras.hpp | 115 --------------------------------------- 1 file changed, 115 deletions(-) diff --git a/src/geom/geom_extras.hpp b/src/geom/geom_extras.hpp index 4d9d6e3..aea0553 100644 --- a/src/geom/geom_extras.hpp +++ b/src/geom/geom_extras.hpp @@ -79,119 +79,4 @@ inline void register_geom_extras(grunk::plugin_namespace& ns) ); ns.modify_type("Geom_Curve").with_std_vector>(); - - // TEMP DIAGNOSTIC (remove once the macOS-only occt.Geom_Curve.as_vec(...) - // failure is root-caused - see grunk-geoml's own DESIGN.md/CI issue this is - // chasing): with_std_vector() above reproduces the real - // bug on macOS even for curves built entirely via occt.* calls (same dylib - // as this registration) - ruling out cross-plugin origin as the cause. A - // hand-rolled replica of the exact same cast_to_element/convert_one logic, - // registered as a plain NAMESPACE function (no usertype, no sol::overload), - // works fine on macOS (grunk-geoml's own debug_as_vec3). The two structural - // differences between that working replica and this real, broken - // with_std_vector()-produced as_vec are (a) usertype member-function - // registration (add_member_function, looked up via `occt.Geom_Curve.as_vec`) - // vs a plain namespace function, and (b) sol::overload(from_table, - // from_varargs) - two candidates - vs one plain lambda. The three probes - // below isolate each factor and their combination, duplicating - // cast_to_element/convert_one inline (not worth factoring out for - // throwaway diagnostic code): - // debug_member_novoverload - member function, no overload (tests (a) alone) - // debug_namespace_overload - namespace function, with overload (tests (b) alone) - // debug_member_overload - both together (expected to fail, reproducing - // the real as_vec exactly, as a sanity check - // that this hand-rolled copy is equivalent) - { - // cast_to_element is built fresh from whichever lua_State the call itself - // carries (va.lua_state()/t.lua_state()) rather than once at registration - // time - plugin_namespace has no lua_state() accessor of its own, and this - // is throwaway diagnostic code, not worth plumbing one through. - auto convert_one = [](auto const& v) -> opencascade::handle { - std::string const ud_name = "Geom_Curve"; - if (v.get_type() != sol::type::userdata) { - throw std::runtime_error("Cannot create std::vector. The values cannot be converted to the expected usertype \"" + ud_name + "\"."); - } - sol::state_view lua(v.lua_state()); - sol::protected_function cast_to_element = sol::make_object( - lua, [](opencascade::handle x) -> opencascade::handle { return x; } - ); - sol::protected_function_result res = cast_to_element(v); - if (!res.valid()) { - throw std::runtime_error("Cannot create std::vector. The values cannot be converted to the expected usertype \"" + ud_name + "\"."); - } - return res.get>(); - }; - auto from_varargs = [convert_one](sol::variadic_args va) { - std::vector> ret; - ret.reserve(va.size()); - for (auto const& v : va) { - ret.push_back(convert_one(v)); - } - return ret; - }; - auto from_table = [convert_one](sol::table t) { - std::vector> ret; - ret.reserve(t.size()); - for (auto const& kv : t) { - ret.push_back(convert_one(kv.second)); - } - return ret; - }; - - ns.modify_type("Geom_Curve").add_member_function("debug_member_novoverload", from_varargs); - ns.register_function("debug_namespace_overload", sol::overload(from_table, from_varargs)); - ns.modify_type("Geom_Curve").add_member_function("debug_member_overload", sol::overload(from_table, from_varargs)); - } - - // TEMP DIAGNOSTIC, round 2 (remove alongside the probes above): all three - // probes above - including debug_member_overload, structurally identical to - // with_std_vector's own add_member_function("as_vec", sol::overload(...)) - // call - PASSED on macOS, while the real occt.Geom_Curve.as_vec(...) still - // fails on the exact same curves (see debug_as_vec_variants.grr.yml's own - // CI results). The one remaining difference: the real with_std_vector() - // builds cast_to_element ONCE, at *registration* time (plugin-load time), - // via `sol::state_view lua(ut.lua_state())` - a single sol::protected_function - // captured by value into convert_one's closure and reused for the lifetime - // of the process. The probes above instead rebuild cast_to_element FRESH on - // *every call* (plugin_namespace has no lua_state() accessor of its own, so - // this was a pragmatic workaround, not a deliberate design choice) - this - // probe removes that difference, building cast_to_element once via the - // usertype_proxy's own `ut.lua_state()` (public member, same accessor - // with_std_vector itself uses), to test whether a persistent, - // registration-time-captured closure is what actually breaks on macOS. - { - auto proxy = ns.modify_type("Geom_Curve"); - std::string const ud_name = "Geom_Curve"; - sol::state_view lua(proxy.ut.lua_state()); - sol::protected_function cast_to_element = sol::make_object( - lua, [](opencascade::handle x) -> opencascade::handle { return x; } - ); - auto convert_one = [ud_name, cast_to_element](auto const& v) -> opencascade::handle { - if (v.get_type() != sol::type::userdata) { - throw std::runtime_error("Cannot create std::vector. The values cannot be converted to the expected usertype \"" + ud_name + "\"."); - } - sol::protected_function_result res = cast_to_element(v); - if (!res.valid()) { - throw std::runtime_error("Cannot create std::vector. The values cannot be converted to the expected usertype \"" + ud_name + "\"."); - } - return res.get>(); - }; - auto from_varargs = [convert_one](sol::variadic_args va) { - std::vector> ret; - ret.reserve(va.size()); - for (auto const& v : va) { - ret.push_back(convert_one(v)); - } - return ret; - }; - auto from_table = [convert_one](sol::table t) { - std::vector> ret; - ret.reserve(t.size()); - for (auto const& kv : t) { - ret.push_back(convert_one(kv.second)); - } - return ret; - }; - ns.modify_type("Geom_Curve").add_member_function("debug_member_overload_persistent_cast", sol::overload(from_table, from_varargs)); - } } From a0cb3798d28076e6d9c2b04e8e601594b88e29f3 Mon Sep 17 00:00:00 2001 From: Jan Kleinert Date: Mon, 23 Nov 2026 16:48:08 +0100 Subject: [PATCH 6/6] sequential ad build because of memory issues on gh runners --- .github/workflows/ci.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac2e967..cf3bb38 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -142,8 +142,14 @@ jobs: - name: Configure run: pixi run -e ad configure Release + # One compile job at a time: the AD translation units are huge (locally + # measured peaks: occt_plugin_tu_1.cpp ~8.8 GB, generated/gp.cpp ~6.4 GB, + # several more at ~2 GB), and the `build` task's bare `--parallel` lets + # Ninja run ~6 jobs on a 4-core/16 GB hosted runner - the runner was + # repeatedly killed mid-build (exit code 143 / "lost communication"). + # Later steps' depends-on `build` then finds nothing left to do. - name: Build - run: pixi run -e ad build + run: pixi run -e ad cmake --build build-ad --parallel 1 - name: Test run: pixi run -e ad test