Commit 41bf1b9
committed
BUG: Harden CopyIterationBenchmark to not crash on ITK 1d87efa52+ regression
The previous CreateAndInitializeImage used
it.Set(static_cast<PixelType>(count));
to seed pixel values. For scalar and FixedArray pixels this
performs a value cast, but for VectorImage (where PixelType is
itk::VariableLengthVector<T>) it invokes the LENGTH constructor —
producing a vector of size 'count', not a N-component pixel with
value 'count'. In particular the first iteration produces a
length-0 VLV, which ITK commit 1d87efa52 changed to store a null
data pointer.
Under ITK >= 1d87efa52, the iterator's implicit copy of
NumberOfComponentsPerPixel elements from that null source causes
a SIGSEGV. Under earlier ITK, the out-of-spec read 'happens to
work' by reading uninitialized memory. Either way, the benchmark
was never constructing semantically correct pixel values for the
VectorImage case.
Introduce a PixelFiller trait that specializes for
VariableLengthVector so the VectorImage branch constructs a
properly sized VLV and Fills it with 'count'. Scalar and
FixedArray branches keep the existing static_cast path.
With this change the benchmark produces well-defined output across
the ITK v5.3 -> main range regardless of the internal
representation of VariableLengthVector(0).1 parent cf89d96 commit 41bf1b9
1 file changed
Lines changed: 42 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
36 | 77 | | |
37 | 78 | | |
38 | 79 | | |
| |||
54 | 95 | | |
55 | 96 | | |
56 | 97 | | |
57 | | - | |
| 98 | + | |
58 | 99 | | |
59 | 100 | | |
60 | 101 | | |
| |||
0 commit comments