Skip to content

Commit 6084a50

Browse files
imikejacksonclaude
andcommitted
BUG: PUCMColorKey thread-races wlenthe lazy lookup-table init
The vendored wlenthe coloring functions cubicToHemi and cubicLowToHemi populate function-static `std::vector<T> irho, omega` lookup tables on first call. Under ParallelDataAlgorithm (e.g. the simplnx ComputeIPFColorsFilter with PUCM kind), multiple TBB workers all see `omega.empty() == true` simultaneously, all enter the resize/iota/ partial_sum block, and the heap allocator eventually trips on a partially-published vector and aborts with `free_small_botch`. The PUCMColorKey per-class singletons in each LaueOps subclass are already serialized by C++11 magic statics during their first construction, so warm the wlenthe dispatch path once in the PUCMColorKey constructor with a benign direction. By the time any worker thread can read the lookup tables they are fully populated. Keeps the vendored wlenthe_orientation_coloring.hpp byte-identical (per the existing comment in PUCMColorKey.cpp about preserving upstream for future re-syncs). Repro: pipeline at /tmp/pucm_ipf_test.d3dpipeline (Small_IN100 .ang read → euler rotate → sample rotate → threshold → Compute IPF Colors with color_key_index=1 PUCM). Pre-fix: crash in `free_small_botch` inside cubicToHemi via 8 parallel workers. Post-fix: runs cleanly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ed272c8 commit 6084a50

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Source/EbsdLib/Utilities/PUCMColorKey.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@ PUCMColorKey::PUCMColorKey(const std::string& rotationPointGroup)
106106
: m_Group(static_cast<Group>(groupFromRotationPointGroup(rotationPointGroup)))
107107
, m_RotationPointGroup(rotationPointGroup)
108108
{
109+
// The wlenthe coloring routines lazily populate static lookup tables
110+
// (cubicToHemi / cubicLowToHemi) on first call. Under ParallelDataAlgorithm
111+
// multiple worker threads race that init and corrupt the table, producing a
112+
// free_small_botch crash. Warm the per-group dispatch path once here so the
113+
// tables are fully populated before any concurrent reader can see them --
114+
// PUCMColorKey instances are themselves constructed under C++11
115+
// magic-statics locks (one per LaueOps subclass singleton), so this
116+
// construction-time warmup is serialized.
117+
const Vec3 k_WarmupDir = {0.5, 0.3, 0.7};
118+
(void)dispatchPucm(static_cast<int>(m_Group), k_WarmupDir);
109119
}
110120

111121
PUCMColorKey::Vec3 PUCMColorKey::direction2Color(const Vec3& direction) const

0 commit comments

Comments
 (0)