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..
This commit is contained in:
Robin Gareus 2022-07-07 22:34:11 +02:00
parent ef2c1d990b
commit 25d1209bb4
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 8 additions and 3 deletions

View File

@ -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<SessionEvent*> (p) << "\n";});
pool->create_per_thread_pool (name, sizeof (SessionEvent), nitems,
#ifndef NDEBUG
[](size_t i, void*p) { std::cout << i << " " << *static_cast<SessionEvent*> (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)

View File

@ -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;