Skip to content

pycvc-gl wasm: link the host with -fexceptions (v3.7.9 publish failure) - #1020

Merged
transfix merged 9 commits into
masterfrom
fix/pycvc-gl-wasm-host-379
Nov 4, 2026
Merged

transfix merged 9 commits into
masterfrom
fix/pycvc-gl-wasm-host-379

Conversation

@transfix

@transfix transfix commented Nov 4, 2026

Copy link
Copy Markdown
Owner

The v3.7.9 tag's publish-pycvc-gl-wasm run (41746570132) failed at "Smoke the installed host". Right after PYCVC_VTK_BRIDGE_OK, pycvc_host aborted under node with Aborted(undefined) from ___cxa_throw.

Cause

cvc, cvcGL and the SWIG wrappers are compiled with -fexceptions. The top-level CMakeLists.txt adds it under Emscripten, because cvc throws and catches as part of its API. bindings/pycvc/wasm/link-host.sh links the host with its own emcc line, and that line had no -fexceptions. Emscripten therefore linked with exception catching off (DISABLE_EXCEPTION_CATCHING), and __cxa_throw became a bare abort(). Every throw ends the program, including one that a catch would take.

Through v3.7.8 the default smoke script only imported modules, and nothing threw. #961 added Exec(make_app()) running a with-lock, the host's first call into libcvc. In the Exec constructor, cvc::state::instance() on the new app looks up the root with app::data<state_ptr>("__state"). That throws boost::bad_any_cast, and the catch creates the root. An -sASSERTIONS --profiling-funcs link of the same host names that throw:

Aborted(Assertion failed: Exception thrown, but exception catching is not enabled. ...)
    at ___cxa_throw
    at void boost::throw_exception<boost::bad_any_cast>(boost::bad_any_cast const&)
    at boost::shared_ptr<cvc::state> cvc::app::data<boost::shared_ptr<cvc::state>>(std::string const&)
    at cvc::state::instancePtr(cvc::app&)
    at cvc::state::instance(cvc::app&)

Changes

  • link-host.sh: link with -fexceptions, and say why in its list of key facts.
  • build-wasm.ps1 (a separate commit): the recipe's Windows-host wasm build, which is how this was verified.
    • It finds the windows swig bundle's library in bin/Lib. Before, configure failed with "Could NOT find SWIG (missing: SWIG_DIR)".
    • It presses past cvcGL's test executables when they fail to link, as build-wasm.sh's -- -k 0 does. This uses a new opt-in -KeepGoing on Invoke-CvcWasmCMakeBuild, which no other recipe uses.
    • It checks that _pycvc.a and _pycvc_gl.a were installed.

The three files are the same in v3.7.9 and master, so both commits apply to v3.7.9 as they are.

Verification

All on a Windows host (sandipaws), with the wasm deps from cvcpkg install-deps cvcpkg/recipes/pycvc-gl-cp312 --platform wasm plus freetype, assimp and imgui, as the workflow installs them, and emsdk 5.0.7 with its node 22.16.0.

  • cvcpkg build pycvc-gl-cp312 --platform wasm --host-platform windows: configure passes, and the closure builds with -k 0.
    • I stopped the build once the cvcGL test executables were all that remained. Each one spends about 20 minutes in wasm-opt -O3 here.
    • Then cmake --build --target pycvc pycvc_gl cvc cvcGL, cmake --install, and link-host.sh with the environment build-wasm.ps1 passes it.
  • The unmodified link-host.sh reproduces the failure: Aborted(undefined) from ___cxa_throw after PYCVC_VTK_BRIDGE_OK, with the same invoke_vi/invoke_viii/invoke_ii stack as the run.
  • With this change, link-host.sh (NODE set) exits 0. The workflow's smoke step, run on the installed host, passes: node exits 0, and the output has PYCVC_VTK_BRIDGE_OK, PYCVC_EXEC_OK and PYCVC_WASM_OK.
  • I did not dispatch the workflow. Its "Upload pycvc_host.wasm" step runs with if: always(), so a dry run would upload a 68 MB artifact too.

Not fixed here

The "Exception ignored in garbage collection ... _lock_unlock_module ... '<garbage>' object is not callable" lines during import pycvc_gl are in v3.7.8's passing run too.

  • An -sSAFE_HEAP=1 link segfaults there. vtkPythonUtil::AddModule calls PyObject_CallObject on an object whose type is garbage, while pycvc_gl's import pulls in vtkmodules.vtkRenderingCore/vtkRenderingOpenGL2.
  • With -sASSERTIONS, the host also reports at exit that address zero was overwritten.
  • Neither fails the release check. Both point at the vtk-python wasm package, or at the --allow-multiple-definition static link, rather than at this change.

ubuntu-latest now runs ubuntu-26.04 with GCC 15.2, whose libstdc++ no
longer brings <algorithm> in through <random>, <thread> and the rest.
state_compression_registry_test stopped compiling on every Linux job
("'sort' is not a member of 'std'"). state_brick_frustum_test's
std::find leaned on the same transitive include. A scan of src, inc,
examples and bindings found no other file calling an <algorithm> or
<numeric> function without reaching the header itself.

(cherry picked from commit e8ec8e7)
The v3.7.9 tag's publish-pycvc-gl-wasm run failed at the host smoke: right
after PYCVC_VTK_BRIDGE_OK, pycvc_host aborted under node with
"Aborted(undefined)" from ___cxa_throw.

cvc, cvcGL and the SWIG wrappers are compiled with -fexceptions (the
top-level CMakeLists.txt adds it under Emscripten). link-host.sh's emcc line
had no -fexceptions, so emscripten linked the host with exception catching
off, and __cxa_throw became a bare abort(). Every throw then ends the
program, even one that a catch would take.

Up to v3.7.8 the default script only imported modules, and nothing threw.
v3.7.9 (#961) added Exec(make_app()) running a with-lock, the host's first
call into libcvc. Its cvc::state::instance() on the new app throws and
catches a boost::bad_any_cast on its first lookup of the root. An
-sASSERTIONS --profiling-funcs link names that throw:
boost::throw_exception<boost::bad_any_cast>, from
app::data<boost::shared_ptr<cvc::state>>, from state::instancePtr.
Two gaps stopped the recipe's Windows-host wasm build:

- SWIG_DIR: the windows swig bundle keeps its library beside swig.exe
  (bin/Lib), not under share/swig/<ver>. The script found nothing, passed
  an empty SWIG_DIR, and configure failed "Could NOT find SWIG (missing:
  SWIG_DIR)". It now falls back to bin/Lib.
- cvcGL adds its test executables unconditionally, and some of them fail
  to link: on Linux, emscripten_fetch without -sFETCH; here, wasm-ld ran
  out of memory on four of them. The shared Invoke-CvcWasmCMakeBuild threw
  on the first failure.
  build-wasm.sh presses on with -- -k 0. The helper gains an opt-in
  -KeepGoing that does the same, and this recipe uses it. The other
  recipes are unchanged. The recipe then checks that _pycvc.a and
  _pycvc_gl.a were installed, as build-wasm.sh does.
ubuntu-latest became the 26.04 image (gcc 15.2), and the jobs that used it broke on a std::sort
without <algorithm>: a toolchain no published bundle is built with. publish-cvcpkg.yml already
pins its linux targets to ubuntu-22.04 (glibc 2.35, gcc 11.4), because an artifact built on a
newer image carries GLIBC_2.x versions an older system can't load.

Pinned to ubuntu-22.04: ci.yml's package-linux and pycvc-linux, ci-recipe.yml's two linux lanes,
and release.yml's linux job (the SDK archives) and its linux sdk-smoke lanes.

(cherry picked from commit e59cbf2)
test_a_python_kernels_wait_for_the_gil_isnt_charged stamps window["from"]
in Python and then makes the C call that holds the GIL. Between the two the
interpreter can hand the GIL to the waiting kernel thread, at an
eval-breaker check, when `hold` is preempted on a busy machine. The kernel
then runs just after the stamp, with no wait, and the precondition assert
(ran_at - from >= 0.2) failed on pycvc-linux / cp312. Such a try is now
retried like the other no-wait cases: a kernel that waited ran after the C
call, at about window["to"].
The first fix did not hold: pycvc-linux / cp312 failed the same
precondition at 3ab5cd2, with the kernel past the hold's end. The hold
itself ran short of its 0.3 s. _PER_ITEM is the best of five runs at
import, and when every run is slow (a busy runner, a frequency step) each
sum(range(n)) finishes early, so ran_at - window["from"] < 0.2 even
though the kernel waited the hold out.

A try whose hold is under 0.25 s now raises what the next hold asks for
by 0.3 / held (at most 3 s) and tries again. A handover before the C call
and an over-long hold count as stalls, as before. Checked against the
build-ariglx pycvc on Windows: with _PER_ITEM made 2x and 4x pessimistic
the old test fails 2 and 3 runs of 3 and this one passes all of them, with
no skips, and the whole file passes 3 of 3.
…-includes

# Conflicts:
#	bindings/pycvc/test_pycvc_state_exec_async.py
@transfix
transfix merged commit 7a5d94a into master Nov 4, 2026
27 checks passed
transfix added a commit that referenced this pull request Nov 7, 2026
…e) (#1020)

The v3.7.9 tag's publish-pycvc-gl-wasm run failed at the host smoke: right
after PYCVC_VTK_BRIDGE_OK, pycvc_host aborted under node with
"Aborted(undefined)" from ___cxa_throw.

cvc, cvcGL and the SWIG wrappers compile with -fexceptions, but
link-host.sh's emcc line did not pass it. So emscripten linked the host with
exception catching off, and every throw aborted, even one a catch would take.
v3.7.9's smoke added Exec(make_app()) (#961), and on a new app
cvc::state::instance() throws and catches a boost::bad_any_cast. The link
now passes -fexceptions.

Separately, build-wasm.ps1 builds on a Windows host:
- it finds the windows swig bundle's library in bin/Lib;
- it presses past cvcGL's test executables when their links fail, through an
  opt-in -KeepGoing on Invoke-CvcWasmCMakeBuild, as build-wasm.sh does with
  -k 0;
- it checks that _pycvc.a and _pycvc_gl.a were installed.

(cherry picked from commit 7a5d94a)
transfix added a commit that referenced this pull request Nov 7, 2026
One conflict: bindings/pycvc/wasm/link-host.sh, where the branch had only master's #1020 (cherry-picked
for the wasm dry run) and master has #1020 and #1027 since; master's file is taken.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant