Skip to content

Commit d7103cd

Browse files
committed
Merge branch 'master' into native_type_lists
2 parents c4e3a24 + 189174c commit d7103cd

30 files changed

+2675
-598
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ jobs:
153153
# Always run tests on weekly builds but skip Debug on commits as they take a while.
154154
# https://github.community/t/distinct-job-for-each-schedule/17811/2
155155
if: contains(github.event.schedule, '0 7 * * 1') || matrix.config.build == 'Release'
156-
run: cd build && ctest -V
156+
run: cd build && ctest -V -C ${{ matrix.config.build }}
157157

158158
testmacos11:
159159
if: |

.github/workflows/weekly.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ jobs:
155155
strategy:
156156
matrix:
157157
config:
158-
- { build: 'asan', cmake: '-DUSE_BLOSC=OFF' } # We never called blosc_destroy(), so disable blosc to silence these errors
159-
- { build: 'ubsan', cmake: '' } # Currently doesn't error, just reports all issues
158+
- { build: 'asan', components: 'core,test,nano,nanotest,axcore,axtest', cmake: '-DUSE_BLOSC=OFF' } # We never called blosc_destroy(), so disable blosc to silence these errors
159+
- { build: 'ubsan', components: 'core,test,axcore,axtest', cmake: '' } # Doesn't currently test NanoVDB
160160
#- { build: 'lsan', cmake: '' } # asan encompasses and includes lsan
161161
#- { build: 'tsan', cmake: '' } # requires full stack rebuild for valid results (including libc++)
162162
#- { build: 'msan', cmake: '' } # requires full stack rebuild for valid results (including libc++)
@@ -168,7 +168,7 @@ jobs:
168168
run: >
169169
./ci/build.sh -v
170170
--build-type=${{ matrix.config.build }}
171-
--components="core,test,nano,nanotest,axcore,axtest"
171+
--components="${{ matrix.config.components }}"
172172
--cargs=\"
173173
-DOPENVDB_CORE_STATIC=OFF
174174
-DOPENVDB_AX_STATIC=OFF

cmake/scripts/ubsan.supp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#################################################################################
2+
## This file is loaded by the Undefined Behaviour Sanitizer build for the unit ##
3+
## tests. It can be used to ignore various errors reported by the sanitizer. ##
4+
## This is especially useful with upstream issues (e.g. boost/tbb). For help ##
5+
## defining suppression rules, see: ##
6+
## https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html ##
7+
## The build is configured with CMAKE_BUILD_TYPE=ubsan. ##
8+
#################################################################################
9+
10+
##### Upstream #####
11+
12+
# Lots of warnings from TBB, ignore them
13+
alignment:tbb/concurrent_hash_map.h
14+
vptr:tbb/parallel_reduce.h
15+
vptr:tbb/task.h
16+
17+
##### OpenVDB #####
18+
19+
# The sOn/sOff static bool data held on the LeaffBuff<bool> objects can be
20+
# initialised to arbitrary true/false values. See the note in LeafBuffer.h
21+
enum:openvdb/tools/Activate.h
22+
# Some 2s complement tests, ignore the negative shifts
23+
# @todo Should address these
24+
shift-base:TestMultiResGrid.cc
25+
shift-base:openvdb/math/Coord.h
26+
27+
##### OpenVDB AX #####
28+
29+
# Ignore overflows reported from old OpenSimplexNoise
30+
signed-integer-overflow:openvdb_ax/math/OpenSimplexNoise.cc

openvdb/openvdb/math/Coord.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ class Coord
229229
template<int Log2N = 20>
230230
size_t hash() const
231231
{
232-
return ((1<<Log2N)-1) & (mVec[0]*73856093 ^ mVec[1]*19349663 ^ mVec[2]*83492791);
232+
const uint32_t* vec = reinterpret_cast<const uint32_t*>(mVec.data());
233+
return ((1<<Log2N)-1) & (vec[0]*73856093 ^ vec[1]*19349663 ^ vec[2]*83492791);
233234
}
234235

235236
private:

openvdb/openvdb/math/Math.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ template<typename Type>
872872
inline Type
873873
Truncate(Type x, unsigned int digits)
874874
{
875-
Type tenth = Pow(10,digits);
875+
Type tenth = static_cast<Type>(Pow(size_t(10), digits));
876876
return RoundDown(x*tenth+0.5)/tenth;
877877
}
878878

openvdb/openvdb/points/PointConversion.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,14 @@ template <typename T> struct ConversionTraits
237237
using WriteHandle = AttributeWriteHandle<T, UnknownCodec>;
238238
static T zero() { return zeroVal<T>(); }
239239
template <typename LeafT>
240-
static typename Handle::Ptr handleFromLeaf(LeafT& leaf, Index index) {
240+
static std::unique_ptr<Handle> handleFromLeaf(const LeafT& leaf, const Index index) {
241241
const AttributeArray& array = leaf.constAttributeArray(index);
242-
return Handle::create(array);
242+
return std::make_unique<Handle>(array);
243243
}
244244
template <typename LeafT>
245-
static typename WriteHandle::Ptr writeHandleFromLeaf(LeafT& leaf, Index index) {
245+
static std::unique_ptr<WriteHandle> writeHandleFromLeaf(LeafT& leaf, const Index index) {
246246
AttributeArray& array = leaf.attributeArray(index);
247-
return WriteHandle::create(array);
247+
return std::make_unique<WriteHandle>(array);
248248
}
249249
}; // ConversionTraits
250250
template <> struct ConversionTraits<openvdb::Name>
@@ -253,16 +253,16 @@ template <> struct ConversionTraits<openvdb::Name>
253253
using WriteHandle = StringAttributeWriteHandle;
254254
static openvdb::Name zero() { return ""; }
255255
template <typename LeafT>
256-
static typename Handle::Ptr handleFromLeaf(LeafT& leaf, Index index) {
256+
static std::unique_ptr<Handle> handleFromLeaf(const LeafT& leaf, const Index index) {
257257
const AttributeArray& array = leaf.constAttributeArray(index);
258258
const AttributeSet::Descriptor& descriptor = leaf.attributeSet().descriptor();
259-
return Handle::create(array, descriptor.getMetadata());
259+
return std::make_unique<Handle>(array, descriptor.getMetadata());
260260
}
261261
template <typename LeafT>
262-
static typename WriteHandle::Ptr writeHandleFromLeaf(LeafT& leaf, Index index) {
262+
static std::unique_ptr<WriteHandle> writeHandleFromLeaf(LeafT& leaf, const Index index) {
263263
AttributeArray& array = leaf.attributeArray(index);
264264
const AttributeSet::Descriptor& descriptor = leaf.attributeSet().descriptor();
265-
return WriteHandle::create(array, descriptor.getMetadata());
265+
return std::make_unique<WriteHandle>(array, descriptor.getMetadata());
266266
}
267267
}; // ConversionTraits<openvdb::Name>
268268

@@ -298,7 +298,7 @@ struct PopulateAttributeOp {
298298

299299
if (!pointIndexLeaf) continue;
300300

301-
typename HandleT::Ptr attributeWriteHandle =
301+
auto attributeWriteHandle =
302302
ConversionTraits<ValueType>::writeHandleFromLeaf(*leaf, static_cast<Index>(mIndex));
303303

304304
Index64 index = 0;
@@ -474,7 +474,7 @@ struct ConvertPointDataGridAttributeOp {
474474

475475
if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
476476

477-
typename SourceHandleT::Ptr handle = ConversionTraits<ValueType>::handleFromLeaf(
477+
auto handle = ConversionTraits<ValueType>::handleFromLeaf(
478478
*leaf, static_cast<Index>(mIndex));
479479

480480
if (mFilter.state() == index::ALL) {

openvdb/openvdb/tree/LeafBuffer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,8 @@ class LeafBuffer<bool, Log2Dim>
446446
/// LeafNode::getValue() return a reference to a value. Since it's not possible
447447
/// to return a reference to a bit in a node mask, we return a reference to one
448448
/// of the following static values instead.
449+
///
450+
/// @todo Make these static inline with C++17
449451
template<Index Log2Dim> const bool LeafBuffer<bool, Log2Dim>::sOn = true;
450452
template<Index Log2Dim> const bool LeafBuffer<bool, Log2Dim>::sOff = false;
451453

openvdb/openvdb/unittest/CMakeLists.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,18 @@ if(USE_BLOSC OR OpenVDB_USES_BLOSC OR USE_ZLIB OR OpenVDB_USES_ZLIB)
208208
list(APPEND OPENVDB_CORE_DEPENDENT_LIBS ZLIB::ZLIB)
209209
endif()
210210

211-
target_link_libraries(vdb_test
212-
${OPENVDB_TEST_DEPENDENT_LIBS}
213-
)
211+
target_link_libraries(vdb_test ${OPENVDB_TEST_DEPENDENT_LIBS})
212+
add_test(NAME vdb_unit_test COMMAND $<TARGET_FILE:vdb_test> -v)
213+
214+
# For the undefined behaviour sanitizer, add the suppression file and
215+
# additional options
216+
217+
get_filename_component(PATH_TO_PROJECT_ROOT ${CMAKE_CURRENT_LIST_DIR} DIRECTORY)
218+
get_filename_component(PATH_TO_PROJECT_ROOT ${PATH_TO_PROJECT_ROOT} DIRECTORY)
219+
get_filename_component(PATH_TO_PROJECT_ROOT ${PATH_TO_PROJECT_ROOT} DIRECTORY)
220+
set(UBSAN_SUPRESSION_FILE ${PATH_TO_PROJECT_ROOT}/cmake/scripts/ubsan.supp)
221+
222+
set_tests_properties(vdb_unit_test PROPERTIES
223+
ENVIRONMENT
224+
"$<$<CONFIG:UBSAN>:UBSAN_OPTIONS=halt_on_error=1 report_error_type=1 suppressions=${UBSAN_SUPRESSION_FILE}>")
214225

215-
add_test(vdb_unit_test vdb_test -v)

openvdb/openvdb/unittest/TestCoord.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ TEST_F(TestCoord, testCoordBBox)
315315
EXPECT_EQ(count, n);
316316
}
317317

318-
{// bit-wise operations
319-
const openvdb::Coord min(-1,-2,3), max(2,3,5);
318+
{// bit-wise operations (note that the API doesn't define behaviour for shifting neg coords)
319+
const openvdb::Coord min(1,2,3), max(2,3,5);
320320
const openvdb::CoordBBox b(min, max);
321321
EXPECT_EQ(openvdb::CoordBBox(min>>1,max>>1), b>>size_t(1));
322322
EXPECT_EQ(openvdb::CoordBBox(min>>3,max>>3), b>>size_t(3));

openvdb/openvdb/unittest/TestIndexIterator.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ TEST_F(TestIndexIterator, testProfile)
321321

322322
{ // for loop
323323
ProfileTimer timer("ForLoop: sum");
324-
volatile int sum = 0;
324+
volatile uint64_t sum = 0;
325325
for (int i = 0; i < elements; i++) {
326326
sum += i;
327327
}
@@ -330,7 +330,7 @@ TEST_F(TestIndexIterator, testProfile)
330330

331331
{ // index iterator
332332
ProfileTimer timer("IndexIter: sum");
333-
volatile int sum = 0;
333+
volatile uint64_t sum = 0;
334334
ValueVoxelCIter iter(0, elements);
335335
for (; iter; ++iter) {
336336
sum += *iter;
@@ -350,7 +350,7 @@ TEST_F(TestIndexIterator, testProfile)
350350

351351
{ // manual value iteration
352352
ProfileTimer timer("ValueIteratorManual: sum");
353-
volatile int sum = 0;
353+
volatile uint64_t sum = 0;
354354
auto indexIter(leafNode.cbeginValueOn());
355355
int offset = 0;
356356
for (; indexIter; ++indexIter) {
@@ -366,7 +366,7 @@ TEST_F(TestIndexIterator, testProfile)
366366

367367
{ // value on iterator (all on)
368368
ProfileTimer timer("ValueIndexIter: sum");
369-
volatile int sum = 0;
369+
volatile uint64_t sum = 0;
370370
auto indexIter(leafNode.cbeginValueAll());
371371
IndexIter<LeafNode::ValueAllCIter, NullFilter>::ValueIndexIter iter(indexIter);
372372
for (; iter; ++iter) {

0 commit comments

Comments
 (0)