Skip to content

Make QuadSurface gen safe for parallel rendering#1054

Open
LubuSeb wants to merge 1 commit into
ScrollPrize:mainfrom
LubuSeb:codex/villa-1046-threadsafe-gen
Open

Make QuadSurface gen safe for parallel rendering#1054
LubuSeb wants to merge 1 commit into
ScrollPrize:mainfrom
LubuSeb:codex/villa-1046-threadsafe-gen

Conversation

@LubuSeb

@LubuSeb LubuSeb commented Jun 18, 2026

Copy link
Copy Markdown

Fixes #1046.

Summary

  • make QuadSurface::gen() safe when vc_render_tifxyz calls it from parallel tile workers
  • move the large coordinate/validity/normal scratch buffers from shared per-surface members to per-thread scratch buffers
  • guard lazy normal-cache rebuilds and snapshot the cache header before warping normals
  • add an empty-source guard to the nearest-neighbor warp helpers
  • add a concurrent QuadSurface::gen() regression test that requests normals from multiple worker threads

Reproduction / Root Cause

Issue #1046 reports SIGSEGVs in vc-render-tifxyz after updating from an April build. The posted stack trace lands in:

QuadSurface::gen -> warpNearestConstVec3f -> orow[dx] = ... srow[sx_i]

vc_render_tifxyz renders tile columns inside an OpenMP loop, and each tile calls genTile(), which calls QuadSurface::gen() on the same QuadSurface.

The recent optimized gen() path reused mutable destination scratch buffers on the surface object:

  • _genCoordsScratch
  • _genValidScratch
  • _genNormalsScratch

Those are written by each gen() call, so parallel tile workers could write and resize the same cv::Mat storage concurrently. The lazy _normalCache build was also unguarded, so first-use normal generation could race.

Scope / Minimality

This patch is limited to:

  • volume-cartographer/core/include/vc/core/util/QuadSurface.hpp
  • volume-cartographer/core/src/QuadSurface.cpp
  • volume-cartographer/core/test/test_quadsurface_components.cpp

It does not change surface-normal orientation policy, vc_render_tifxyz command-line options, renderer output semantics, or scheduling.

Issue / Artifact Binding

  • Issue: vc-render-tifxyz fails with sigsegv #1046
  • Artifact: this pull request from LubuSeb:codex/villa-1046-threadsafe-gen
  • Prize context: Vesuvius Challenge monthly progress prizes may consider VC/tooling improvements; this PR is the reviewable technical artifact, not a guaranteed award request.

Validation

Run in the project Docker builder:

cmake --preset ci-tests-gcc
cmake --build --preset ci-tests-gcc --target vc_render_tifxyz
cmake --build --preset ci-tests-gcc --target test_quadsurface_components
./build/ci-tests-gcc/bin/test_quadsurface_components
cmake --build --preset ci-tests-gcc
ctest --preset ci-tests-gcc --output-on-failure

Results:

  • vc_render_tifxyz built successfully.
  • test_quadsurface_components passed, including the new concurrent QuadSurface::gen() regression.
  • Full configured CTest passed: 97/97 tests.
  • git diff --check passed; only Windows LF-to-CRLF warnings were emitted by Git.

Known Limits

I did not have the private/large segment dataset that produced the original backtrace, so I validated the failure mode with a focused concurrency regression and the full Dockerized test suite rather than a direct data replay.

This is also a normal GitHub PR contribution. It may be relevant for Vesuvius monthly progress-prize review, but this PR does not claim or guarantee an award.

@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

@LubuSeb is attempting to deploy a commit to the scroll Team on Vercel.

A member of the Team first needs to authorize it.

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.

vc-render-tifxyz fails with sigsegv

1 participant