GothicKit / ZenKit

A re-implementation of file formats used by the early 2000's ZenGin
http://zk.gothickit.dev/
MIT License
44 stars 9 forks source link

Out of memory crash while parsing `ORCGRAVEYARD.ZEN` #60

Closed thokkat closed 1 year ago

thokkat commented 1 year ago

callstack:

==50686==ERROR: AddressSanitizer: allocator is out of memory trying to allocate 0x38c8000000 bytes
    #0 0x7f54dd4c0672 in operator new(unsigned long) /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_new_delete.cpp:95
    #1 0x56196bdd21d5 in std::__new_allocator<phoenix::material>::allocate(unsigned long, void const*) /usr/include/c++/12.2.1/bits/new_allocator.h:137
    #2 0x56196bdca6b9 in std::allocator_traits<std::allocator<phoenix::material> >::allocate(std::allocator<phoenix::material>&, unsigned long) /usr/include/c++/12.2.1/bits/alloc_traits.h:464
    #3 0x56196bdc18f1 in std::_Vector_base<phoenix::material, std::allocator<phoenix::material> >::_M_allocate(unsigned long) /usr/include/c++/12.2.1/bits/stl_vector.h:378
    #4 0x56196bdbbb98 in std::vector<phoenix::material, std::allocator<phoenix::material> >::reserve(unsigned long) /usr/include/c++/12.2.1/bits/vector.tcc:79
    #5 0x56196bdb3f33 in phoenix::mesh::parse(phoenix::buffer&, std::unordered_set<unsigned int, std::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<unsigned int> > const&) /mnt/tmp/phoenix/source/mesh.cc:52
    #6 0x56196bf88e79 in phoenix::world::parse(phoenix::buffer&, phoenix::game_version) /mnt/tmp/phoenix/source/world.cc:87
    #7 0x56196bf8da42 in phoenix::world::parse(phoenix::buffer&) /mnt/tmp/phoenix/source/world.cc:212
    #8 0x56196bca658c in DOCTEST_ANON_FUNC_3 /mnt/tmp/phoenix/tests/test_world.cc:9

Happens with new parser as well.

lmichaelis commented 1 year ago

Thanks for the report @thokkat. I've located the error and I'll have a fix up shortly :)

lmichaelis commented 1 year ago

This patch should fix it :)

thokkat commented 1 year ago

Works. Thanks once again for the quick reaction and fix.