oatpp: oatpp::base::memory::MemoryPool::freeByEntryHeader()]: Invalid EntryHeader
Hi!
I observe this exception when I’m stopping the application with OATPP:
terminate called after throwing an instance of 'std::runtime_error'
what(): [oatpp::base::memory::MemoryPool::freeByEntryHeader()]: Invalid EntryHeader
I was able to get some more logs of it:
2020-09-16T13:31:24.530436Z DBG 322058:src/log/oatpp_logger.hpp:20 [oatpp::base::memory::MemoryPool::freeByEntryHeader()]:Error. Invalid EntryHeader. Expected poolId=9803840, entry poolId=-1610486112
Backtrace:
(gdb) bt
#0 0x00007f775e5e370f in raise () from /lib64/libc.so.6
#1 0x00007f775e5cdb25 in abort () from /lib64/libc.so.6
#2 0x00007f770a4fd06b in __gnu_cxx::__verbose_terminate_handler() [clone .cold.1] () from /lib64/libstdc++.so.6
#3 0x00007f770a50350c in __cxxabiv1::__terminate(void (*)()) () from /lib64/libstdc++.so.6
#4 0x00007f770a502529 in __cxa_call_terminate () from /lib64/libstdc++.so.6
#5 0x00007f770a502ea8 in __gxx_personality_v0 () from /lib64/libstdc++.so.6
#6 0x00007f770a265ad3 in _Unwind_RaiseException_Phase2 () from /lib64/libgcc_s.so.1
#7 0x00007f770a266041 in _Unwind_RaiseException () from /lib64/libgcc_s.so.1
#8 0x00007f770a5037bb in __cxa_throw () from /lib64/libstdc++.so.6
#9 0x00007f770a985b5e in oatpp::base::memory::MemoryPool::freeByEntryHeader(oatpp::base::memory::MemoryPool::EntryHeader*) [clone .cold.96] ()
#10 0x00007f770ab09aea in std::_Sp_counted_ptr_inplace<oatpp::collection::LinkedList<std::shared_ptr<oatpp::web::url::mapping::Pattern::Part> >, oatpp::base::memory::PoolSharedObjectAllocator<oatpp::collection::LinkedList<std::shared_ptr<oatpp::web::url::mapping::Pattern::Part> > >, (__gnu_cxx::_Lock_policy)2>::_M_dispose() ()
#11 0x00007f770ab09ebf in oatpp::web::url::mapping::Pattern::~Pattern() ()
#12 0x00007f770aaff249 in oatpp::web::url::mapping::Router<oatpp::web::server::HttpRequestHandler>::~Router() ()
#13 0x00007f770aaff04e in oatpp::web::server::HttpRouter::~HttpRouter() ()
#14 0x00007f770aa7e979 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x236b650) at /usr/include/c++/8/bits/shared_ptr_base.h:148
#15 std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x236b650) at /usr/include/c++/8/bits/shared_ptr_base.h:148
#16 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x23a32c0, __in_chrg=<optimized out>) at /usr/include/c++/8/bits/shared_ptr_base.h:728
#17 std::__shared_ptr<oatpp::web::server::HttpRouter, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=0x23a32b8, __in_chrg=<optimized out>) at /usr/include/c++/8/bits/shared_ptr_base.h:1167
#18 std::shared_ptr<oatpp::web::server::HttpRouter>::~shared_ptr (this=0x23a32b8, __in_chrg=<optimized out>) at /usr/include/c++/8/bits/shared_ptr.h:103
#19 oatpp::base::Environment::Component<std::shared_ptr<oatpp::web::server::HttpRouter> >::~Component (this=0x23a3278, __in_chrg=<optimized out>)
at /root/.conan/data/oatpp/1.1.0/_/_/package/56e0cf6d16ee57367a0661ab743f4e43b29223f8/include/oatpp-1.1.0/oatpp/oatpp/core/base/Environment.hpp:242
#20 zroute::ServiceComponent::~ServiceComponent (this=0x23a3170, __in_chrg=<optimized out>)
#21 std::default_delete<zroute::ServiceComponent>::operator() (this=0x23a4020, __ptr=0x23a3170) at /usr/include/c++/8/bits/unique_ptr.h:81
#22 std::unique_ptr<zroute::ServiceComponent, std::default_delete<zroute::ServiceComponent> >::~unique_ptr (this=0x23a4020, __in_chrg=<optimized out>) at /usr/include/c++/8/bits/unique_ptr.h:269
#23 zroute::HttpServer::~HttpServer (this=0x23a3f90, __in_chrg=<optimized out>)
#24 0x00007f770a9ac001 in std::default_delete<zroute::HttpServer>::operator() (this=0x7f770e5299c0, __ptr=0x23a3f90) at /usr/include/c++/8/bits/unique_ptr.h:342
#25 std::unique_ptr<zroute::HttpServer, std::default_delete<zroute::HttpServer> >::~unique_ptr (this=0x7f770e5299c0, __in_chrg=<optimized out>) at /usr/include/c++/8/bits/unique_ptr.h:269
#26 zroute::core::~core (this=0x7f770e529910, __in_chrg=<optimized out>)
#27 core_cleanup ()
#28 0x00007f770a9a2eff in destroy () at inroute_mod.c:137
#29 0x0000000000582a18 in destroy_modules () at core/sr_module.c:746
#30 0x000000000041d53d in cleanup (show_status=1) at main.c:563
#31 0x000000000041ed12 in shutdown_children (sig=15, show_status=1) at main.c:706
#32 0x000000000041f800 in handle_sigs () at main.c:737
#33 0x000000000042b465 in main_loop () at main.c:1817
#34 0x0000000000433137 in main (argc=13, argv=0x7ffd84f9ea78) at main.c:2856
The issue started to occur after I added 2nd controller. There was no such issue with single controller.
OATPP version is 1.1.0
After I disabled pool allocation the issue doesn’t reproduce anymore:
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,7 +26,7 @@ option(OATPP_BUILD_TESTS "Create test target for oat++" ON)
###################################################################################################
.
option(OATPP_DISABLE_ENV_OBJECT_COUNTERS "Disable object counting for Release builds for better performance" OFF)
-option(OATPP_DISABLE_POOL_ALLOCATIONS "This will make oatpp::base::memory::MemoryPool, method obtain and free call new and delete directly" OFF)
+option(OATPP_DISABLE_POOL_ALLOCATIONS "This will make oatpp::base::memory::MemoryPool, method obtain and free call new and delete directly" ON)
.
set(OATPP_THREAD_HARDWARE_CONCURRENCY "AUTO" CACHE STRING "Predefined value for function oatpp::concurrency::Thread::getHardwareConcurrency()")
set(OATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT "10" CACHE STRING "Number of shards of ThreadDistributedMemoryPool")
Looks to be connected with https://github.com/oatpp/oatpp/issues/173
Is this a bug at OATPP custom pool memory allocator?
Thanks in advance.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (20 by maintainers)
Commits related to this issue
- Merge pull request #314 from pcapdump/issue_308 Issue #308: oatpp::base::memory::MemoryPool::freeByEntryHeader()]: Invalid EntryHeader — committed to oatpp/oatpp by lganzzzo 4 years ago
Leonid, please review PR https://github.com/oatpp/oatpp/pull/314
Alas, it doesn’t work without
std::call_once
. It was my 1st attempt to try without it: https://github.com/oatpp/oatpp/pull/314/commits/6974e708bf4641e667aa187d64a91804e595efad And unit tests failed: https://github.com/oatpp/oatpp/runs/1192140265 Looks like there is a concurrency issue.With
std::call_once
all checks pass.