From 691578820b9b6ab3285869ab14bc51f757491c8a Mon Sep 17 00:00:00 2001 From: Adrian Knoth Date: Sat, 11 Jun 2016 05:07:13 +0200 Subject: [PATCH] Heap-allocate client matrix in topo sort If configured with --clients=512 (translates to CLIENT_NUM), we exceed the maximum stack size. CLIENT_NUM==500 still works, but let's allocate the matrix on the heap to be safe. Kudos to Markus Seeber for the initial bug triage. Fixes #212 --- common/JackConnectionManager.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/common/JackConnectionManager.cpp b/common/JackConnectionManager.cpp index cefb39fd..8b5384f9 100644 --- a/common/JackConnectionManager.cpp +++ b/common/JackConnectionManager.cpp @@ -286,10 +286,10 @@ static bool HasNoConnection(jack_int_t* table) void JackConnectionManager::TopologicalSort(std::vector& sorted) { - JackFixedMatrix tmp; + JackFixedMatrix* tmp = new JackFixedMatrix; std::set level; - fConnectionRef.Copy(tmp); + fConnectionRef.Copy(*tmp); // Inputs of the graph level.insert(AUDIO_DRIVER_REFNUM); @@ -299,18 +299,20 @@ void JackConnectionManager::TopologicalSort(std::vector& sorted) jack_int_t refnum = *level.begin(); sorted.push_back(refnum); level.erase(level.begin()); - const jack_int_t* output_ref1 = tmp.GetItems(refnum); + const jack_int_t* output_ref1 = tmp->GetItems(refnum); for (int dst = 0; dst < CLIENT_NUM; dst++) { if (output_ref1[dst] > 0) { - tmp.ClearItem(refnum, dst); + tmp->ClearItem(refnum, dst); jack_int_t output_ref2[CLIENT_NUM]; - tmp.GetOutputTable1(dst, output_ref2); + tmp->GetOutputTable1(dst, output_ref2); if (HasNoConnection(output_ref2)) { level.insert(dst); } } } } + + delete tmp; } /*!