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

Out of memory crash while parsing ORCGRAVEYARD.ZEN #60

Closed
thokkat opened this issue Mar 2, 2023 · 3 comments
Closed

Out of memory crash while parsing ORCGRAVEYARD.ZEN #60

thokkat opened this issue Mar 2, 2023 · 3 comments
Assignees
Labels
awaiting verification The problem has been fixed, though external verification of this fix is required bug Something isn't working
Milestone

Comments

@thokkat
Copy link
Contributor

thokkat commented Mar 2, 2023

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 lmichaelis self-assigned this Mar 3, 2023
@lmichaelis lmichaelis added the bug Something isn't working label Mar 3, 2023
@lmichaelis lmichaelis added this to the v2.0.0 milestone Mar 3, 2023
@lmichaelis
Copy link
Member

lmichaelis commented Mar 3, 2023

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

lmichaelis added a commit that referenced this issue Mar 3, 2023
Previously, the parser for binary archives would parse the last element of the ZEN header (which is "END") and proceed to skip whitespace after it.

This can cause the parser to read bytes of the content of the archive, not belonging to the header, should they start with `0x20`, `\t`, `\v`, `\f`, `\r` or '\n'. This fix introduces a customizable version of `buffer::get_line` which allows the caller to specify the byte values to skip.
@lmichaelis
Copy link
Member

This patch should fix it :)

@lmichaelis lmichaelis added the awaiting verification The problem has been fixed, though external verification of this fix is required label Mar 3, 2023
@thokkat
Copy link
Contributor Author

thokkat commented Mar 3, 2023

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

@thokkat thokkat closed this as completed Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting verification The problem has been fixed, though external verification of this fix is required bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants