Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feature/nanovdb) [BUG] access violation in dstLeaf->data() #1959

Open
dm-tesla opened this issue Nov 1, 2024 · 0 comments
Open

(feature/nanovdb) [BUG] access violation in dstLeaf->data() #1959

dm-tesla opened this issue Nov 1, 2024 · 0 comments
Labels

Comments

@dm-tesla
Copy link

dm-tesla commented Nov 1, 2024

Environment

Operating System: Ubuntu 24.04 LTS
Version / Commit SHA: SHA: 4a186c2 (head of "feature/nanovdb")
Other: clang-18.1.3

Describe the bug

"misaligned pointer use" in this instruction

            auto *srcLeaf = srcLeafs[i];
            auto *dstLeaf = PtrAdd<DstNode0>(ptr, srcLeaf->mDstOffset);
            auto *data = dstLeaf->data(); // <<------ HERE
            srcLeaf->mDstNode = dstLeaf;

I believe it's coming from writeGrid, but the call stacks aren't always looking the same.

To Reproduce

All I'm doing is this:

         nanovdb::GridBuilder<float> builder(0.0f, nanovdb::GridClass::LevelSet);
        auto acc = builder.getAccessor();
        for (uint32_t z = 0; z < extent[2]; ++z)
        {
            for (uint32_t y = 0; y < extent[1]; ++y)
            {
                for (uint32_t x = 0; x < extent[0]; ++x)
                {
                    acc.setValue(nanovdb::Coord(x, y, z), some_value);
                }
            }
        }
        nanovdb::io::writeGrid("grid.nvdb", builder.getHandle<>(), nanovdb::io::Codec::NONE);

Expected behavior

No crashes or access violations are expected.

Additional context

The grid size I used was 23x25x27
The template parameter for the grid is a custom type that has the size of 2 bytes.
The template parameter is just float

Call stack

__ubsan_on_report (Unknown Source:0)
__ubsan::Diag::~Diag() (Unknown Source:0)
handleTypeMismatchImpl(__ubsan::TypeMismatchData*, unsigned long, __ubsan::ReportOptions) (Unknown Source:0)
__ubsan_handle_type_mismatch_v1 (Unknown Source:0)
std::enable_if<!is_same<nanovdb::Fp4, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::Fp8, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::Fp16, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::FpN, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value, void>::type nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::processLeafs<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf>(std::vector<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf*, std::allocator<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf*>>&)::'lambda'(nanovdb::Range<1, unsigned long> const&)::operator()(nanovdb::Range<1, unsigned long> const&) const (deps/nanovdb/nanovdb/util/GridBuilder.h:704)
nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf std::__invoke_impl<void, std::enable_if<!is_same<nanovdb::Fp4, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::Fp8, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::Fp16, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::FpN, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value, void>::type nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::processLeafs<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf>(std::vector<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf*, std::allocator<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf*>>&)::'lambda'(nanovdb::Range<1, unsigned long> const&), nanovdb::Range<1, unsigned long>>(std::__invoke_other, std::enable_if<!is_same<nanovdb::Fp4, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::Fp8, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::Fp16, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::FpN, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value, void>::type nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::processLeafs<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf>(std::vector<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf*, std::allocator<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf*>>&)::'lambda'(nanovdb::Range<1, unsigned long> const&)&&, nanovdb::Range<1, unsigned long>&&) (/usr/include/c++/13/bits/invoke.h:61)
std::__invoke_result<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf, nanovdb::Range<1, unsigned long>>::type std::__invoke<std::enable_if<!is_same<nanovdb::Fp4, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::Fp8, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::Fp16, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::FpN, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value, void>::type nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::processLeafs<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf>(std::vector<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf*, std::allocator<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf*>>&)::'lambda'(nanovdb::Range<1, unsigned long> const&), nanovdb::Range<1, unsigned long>>(nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf&&, nanovdb::Range<1, unsigned long>&&) (/usr/include/c++/13/bits/invoke.h:96)
void std::thread::_Invoker<std::tuple<std::enable_if<!is_same<nanovdb::Fp4, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::Fp8, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::Fp16, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::FpN, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value, void>::type nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::processLeafs<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf>(std::vector<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf*, std::allocator<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf*>>&)::'lambda'(nanovdb::Range<1, unsigned long> const&), nanovdb::Range<1, unsigned long>>>::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) (/usr/include/c++/13/bits/std_thread.h:292)
std::thread::_Invoker<std::tuple<std::enable_if<!is_same<nanovdb::Fp4, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::Fp8, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::Fp16, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::FpN, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value, void>::type nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::processLeafs<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf>(std::vector<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf*, std::allocator<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf*>>&)::'lambda'(nanovdb::Range<1, unsigned long> const&), nanovdb::Range<1, unsigned long>>>::operator()() (/usr/include/c++/13/bits/std_thread.h:299)
std::thread::_State_impl<std::thread::_Invoker<std::tuple<std::enable_if<!is_same<nanovdb::Fp4, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::Fp8, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::Fp16, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value && !is_same<nanovdb::FpN, nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf::BuildType>::value, void>::type nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::processLeafs<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf>(std::vector<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf*, std::allocator<nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::BuildLeaf*>>&)::'lambda'(nanovdb::Range<1, unsigned long> const&), nanovdb::Range<1, unsigned long>>>>::_M_run() (/usr/include/c++/13/bits/std_thread.h:244)
___lldb_unnamed_symbol8048 (Unknown Source:0)
___lldb_unnamed_symbol3670 (Unknown Source:0)
___lldb_unnamed_symbol4062 (Unknown Source:0)

Another call stack:

__ubsan_on_report (Unknown Source:0)
__ubsan::Diag::~Diag() (Unknown Source:0)
handleTypeMismatchImpl(__ubsan::TypeMismatchData*, unsigned long, __ubsan::ReportOptions) (Unknown Source:0)
__ubsan_handle_type_mismatch_v1 (Unknown Source:0)
nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::processTree() (deps/nanovdb/nanovdb/util/GridBuilder.h:937)
nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::processGrid(nanovdb::Map const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) (deps/nanovdb/nanovdb/util/GridBuilder.h:990)
nanovdb::GridHandle<nanovdb::HostBuffer> nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::getHandle<nanovdb::AbsDiff, nanovdb::HostBuffer>(nanovdb::Map const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, nanovdb::AbsDiff const&, nanovdb::HostBuffer const&) (deps/nanovdb/nanovdb/util/GridBuilder.h:586)
nanovdb::GridHandle<nanovdb::HostBuffer> nanovdb::GridBuilder<float, float, nanovdb::Stats<float, 0>>::getHandle<nanovdb::AbsDiff, nanovdb::HostBuffer>(double, nanovdb::Vec3<double> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, nanovdb::AbsDiff const&, nanovdb::HostBuffer const&) (deps/nanovdb/nanovdb/util/GridBuilder.h:559)
main::$_0::operator()(tesla::sim::Voxel const*, std::array<unsigned int, 3ul>, AxisAlignedBoundingBox) const (src/bin/voxelizer.cpp:130)
@dm-tesla dm-tesla added the bug label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant