[PATCH] D25154: [libc++] Fix stack_allocator

Stephan T. Lavavej via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 7 16:42:42 PDT 2016


STL_MSFT added a comment.

F2472251: msvc_warnings.txt <https://reviews.llvm.org/F2472251>

- The attached patch on top of your patch fixes two simple MSVC warnings - unreferenced formal parameter and class/struct mismatch.

- Three tests are emitting stack consumption warnings (since MSVC /analyze tries to understand what's going on in the stack):

test\std\containers\sequences\deque\deque.cons\iter_iter.pass.cpp
iter_iter.pass.cpp(50) : warning C6262: Function uses '32868' bytes of stack:  exceeds /analyze:stacksize '16384'.  Consider moving some data to heap.

test\std\containers\sequences\deque\deque.cons\size.pass.cpp
size.pass.cpp(85) : warning C6262: Function uses '800032' bytes of stack:  exceeds /analyze:stacksize '16384'.  Consider moving some data to heap.

test\std\containers\sequences\deque\deque.cons\size_value_alloc.pass.cpp
size_value_alloc.pass.cpp(34) : warning C6262: Function uses '80044' bytes of stack:  exceeds /analyze:stacksize '16384'.  Consider moving some data to heap.

The 800KB consumption seems especially egregious. Changing these tests to dynamically allocate these huge objects will silence the warning.

- Finally, the following tests are asserting:

test\std\containers\sequences\vector\vector.capacity\reserve.pass.cpp
test\std\containers\sequences\vector\vector.capacity\resize_size.pass.cpp
test\std\containers\sequences\vector\vector.capacity\resize_size_value.pass.cpp
test\std\containers\sequences\vector\vector.cons\construct_iter_iter_alloc.pass.cpp
test\std\containers\sequences\vector\vector.cons\construct_size_value_alloc.pass.cpp
test\std\containers\sequences\vector\vector.modifiers\push_back.pass.cpp
test\std\containers\sequences\vector\vector.modifiers\push_back_rvalue.pass.cpp

This is because of the exact-space-consumption issue I feared/predicted - you're constructing stack_allocators with a small fixed amount of space, but our debug object occupies space, and that makes the allocator run out of memory.

A possible fix would be to increase the amount of space (two pointers should be sufficient).


https://reviews.llvm.org/D25154





More information about the cfe-commits mailing list