TheOpenSpaceProgram / osp-magnum

A spaceship game
https://www.openspaceprogram.org/
MIT License
216 stars 32 forks source link

Crash on startup with failing debug assert #254

Open jonesmz opened 1 year ago

jonesmz commented 1 year ago
1  ??                                                                                                               0x7ffff6eaea1c 
2  raise                                                                                                            0x7ffff6e60486 
3  abort                                                                                                            0x7ffff6e49877 
4  std::__glibcxx_assert_fail                                                           debug.cc                61  0x7ffff7121d3f 
5  std::unique_ptr<unsigned long [], std::default_delete<unsigned long []>>::operator[] unique_ptr.h            724 0x55555559cbfc 
6  lgrn::HierarchicalBitset<unsigned long>::resize                                      hierarchical_bitset.hpp 471 0x5555555c972c 
7  lgrn::IdRegistry<osp::PkgId, false>::reserve                                         registry.hpp            69  0x5555555cd06c 
8  lgrn::IdRegistry<osp::PkgId, false>::create<osp::PkgId *>                            registry.hpp            109 0x5555555cb30f 
9  lgrn::IdRegistry<osp::PkgId, false>::create                                          registry.hpp            38  0x5555555c9ec6 
10 osp::Resources::pkg_create                                                           Resources.cpp           111 0x5555555c8d33 
11 load_a_bunch_of_stuff                                                                main.cpp                368 0x555555734c2f 
12 main                                                                                 main.cpp                150 0x555555733755 
jonesmz commented 1 year ago

    constexpr HierarchicalBitset() = default;

    /**
     * @brief Construct with size
     *
     * @param size [in] Size in bits
     * @param fill [in] Initialize with 1 bits if true
     */
    HierarchicalBitset(std::size_t size, bool fill = false)
     : m_size{size}
     , m_topLevel{0}
     , m_blockCount{ calc_blocks_recurse(size, 0, m_topLevel, m_rows) }
     , m_blocks{ std::make_unique<BLOCK_INT_T[]>(m_blockCount) }
    {
        if (fill)
        {
            set();
        }
    }

lgrn::HierarchicalBitset has a parameterized constructor, but also a default constructor.

In the default constructor, the std::unique_ptr isn't given a buffer, but the rest of the functions of the class assume it has something.

jonesmz commented 1 year ago

Removing the default constructor and changing the parameterized constructor to

    HierarchicalBitset(std::size_t size = 0, bool fill = false)

(Set the size variable to 0 by default)

gets past the crash.

Capital-Asterisk commented 1 year ago

Is the longeron++ submodule up to date? I'm pretty sure I fixed this already and updated the submodule.

https://github.com/Capital-Asterisk/longeronpp/issues/16

I forgot where exactly, but it's not suppose to be calling the default constructor at all, so changing the constructor there would likely cause an error elsewhere

jonesmz commented 1 year ago

my local source checkout is on commit 1f8b0715fd4e7bb36811acd2636539c9f9e43f88 of longeronpp