From 25d1209bb433669c446b413dd6170fdfa425d8cd Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 7 Jul 2022 22:34:11 +0200 Subject: [PATCH] Only dump SessionEvent pool in debug builds This ensures that the user will see a "POOL OUT OF MEMORY" message. In rare case dumping the pool can segfault when printing the Event, The pool is zero initialized and only ever contains events, so in theory it is safe to print them.. --- libs/ardour/session_events.cc | 8 +++++++- libs/pbd/pool.cc | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libs/ardour/session_events.cc b/libs/ardour/session_events.cc index 309c7f93e7..22deeedac7 100644 --- a/libs/ardour/session_events.cc +++ b/libs/ardour/session_events.cc @@ -67,7 +67,13 @@ SessionEvent::create_per_thread_pool (const std::string& name, uint32_t nitems) a CrossThreadPool for use by this thread whenever events are allocated/released from SessionEvent::pool() */ - pool->create_per_thread_pool (name, sizeof (SessionEvent), nitems, [](size_t i, void*p) { std::cout << i << " " << *static_cast (p) << "\n";}); + pool->create_per_thread_pool (name, sizeof (SessionEvent), nitems, +#ifndef NDEBUG + [](size_t i, void*p) { std::cout << i << " " << *static_cast (p) << "\n"; } +#else + NULL +#endif + ); } SessionEvent::SessionEvent (Type t, Action a, samplepos_t when, samplepos_t where, double spd, bool yn, bool yn2, bool yn3) diff --git a/libs/pbd/pool.cc b/libs/pbd/pool.cc index d14507d9e6..e1269c2359 100644 --- a/libs/pbd/pool.cc +++ b/libs/pbd/pool.cc @@ -86,13 +86,12 @@ Pool::alloc () if (free_list.read (&ptr, 1) < 1) { PBD::stacktrace (std::cerr, 20); - if (_dump) { + printf ("RingBuffer write-idx: %u read-idx: %u\n", free_list.get_write_idx (), free_list.get_read_idx ()); void** _block = free_list.buffer (); for (size_t i = 0; i < free_list.bufsize (); ++i) { _dump (i, _block[i]); } - printf ("RingBuffer write-idx: %u read-idx: %u\n", free_list.get_write_idx (), free_list.get_read_idx ()); } fatal << "CRITICAL: " << _name << " POOL OUT OF MEMORY - RECOMPILE WITH LARGER SIZE!!" << endmsg;