gcpp icon indicating copy to clipboard operation
gcpp copied to clipboard

deferred_heap.h:511 "attempt to dereference null"

Open hia3 opened this issue 6 years ago • 1 comments

When compiling the code with STL's STL (that comes with VS2017)

#include "deferred_allocator.h"
using namespace gcpp;

int main()
{
    deferred_heap h;
    using my_map = deferred_unordered_map<int, int>;
    deferred_ptr<my_map> scopes(h.make<my_map>(h));
}

it fails at deferred_heap.h:511

image

hia3 avatar Jan 28 '18 14:01 hia3

This also happens in test_basic

deferred_heap heap;
auto v = deferred_vector<widget>(heap);
test_basic`gcpp::deferred_allocator<widget>::deferred_allocator(this=0x0000007fffffedd0, h_=0x0000007fffffee20) at deferred_allocator.h:66:9

deferred_allocator(deferred_heap& h_) noexcept
: h{ h_ }
(lldb) expr -R -- v
(gcpp::deferred_vector<widget>) $10 = {
  std::__ndk1::__vector_base<widget, gcpp::deferred_allocator<widget> > = {
    __begin_ = {
      gcpp::deferred_heap::deferred_ptr_void = {
        myheap = nullptr
        p = 0x0000000000000000
      }
    }
    __end_ = {
      gcpp::deferred_heap::deferred_ptr_void = {
        myheap = nullptr
        p = 0x0000000000000000
      }
    }
    __end_cap_ = {
      std::__ndk1::__compressed_pair_elem<gcpp::deferred_ptr<widget>, 0, false> = {
        __value_ = {
          gcpp::deferred_heap::deferred_ptr_void = {
            myheap = nullptr
            p = 0x0000000000000000
          }
        }
      }
      std::__ndk1::__compressed_pair_elem<gcpp::deferred_allocator<widget>, 1, false> = {
        __value_ = {
          h = 0x0000007fffffee20
        }
      }
    }
  }
}
test_basic`gcpp::deferred_ptr<widget>::operator->(this=0x0000007fffffedd8) const at deferred_heap.h:511:4

Expects(get() && "attempt to dereference null");
test_basic`test_deferred_allocator_vector() at test.cpp:285:6

v.push_back(i); // i = 1

mgood7123 avatar Apr 29 '23 14:04 mgood7123