jackaudio/jack2 — Issue #5: segfault at startup when compiled with --profile
Author: adiknoth
Created: 2012-03-08 17:39:52+00:00
State: open

Starting program: /tmp/jacktest/bin/jackd -n test -d dummy -C 2 -P 2
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
jackdmp 1.9.9
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2012 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
[New Thread 0x7ffff41fa700 (LWP 31356)]
[New Thread 0x7ffff37f8700 (LWP 31357)]
ALSA lib conf.c:1220:(parse_def) show is not a compound
ALSA lib conf.c:1686:(snd_config_load1) _toplevel_:24:26:Unexpected char
ALSA lib conf.c:3406:(config_file_open) /usr/share/alsa/pulse-alsa.conf may be old or corrupted: consider to remove or fix it
[New Thread 0x7fffeee91700 (LWP 31358)]
JACK server starting in realtime mode with priority 10
Engine profiling activated, beware 197 MBytes are needed to record profiling points...
[New Thread 0x7ffff7fd1700 (LWP 31359)]
[New Thread 0x7ffff7f50700 (LWP 31360)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7f50700 (LWP 31360)]
0x00007ffff78609a2 in Jack::JackEngineControl::CalcCPULoad (
this=0x7fffdd225000, table=0x6081c0, manager=0x7fffe9822000,
cur_cycle_begin=3218338954874, prev_cycle_end=1)
at ../common/JackEngineControl.cpp:57
57 fRollingClientUsecs[fRollingClientUsecsIndex++] = last_cycle_end - fPrevCycleTime;
(gdb) bt
#0 0x00007ffff78609a2 in Jack::JackEngineControl::CalcCPULoad (
this=0x7fffdd225000, table=0x6081c0, manager=0x7fffe9822000,
cur_cycle_begin=3218338954874, prev_cycle_end=1)
at ../common/JackEngineControl.cpp:57
#1 0x00007ffff788014c in Jack::JackEngineControl::CycleBegin (
this=0x7fffdd225000, table=0x6081c0, manager=0x7fffe9822000,
cur_cycle_begin=3218338954874, prev_cycle_end=1)
at ../common/JackEngineControl.h:146
#2 0x00007ffff787c9f3 in Jack::JackEngine::Process (this=0x608180,
cur_cycle_begin=3218338954874, prev_cycle_end=1)
at ../common/JackEngine.cpp:177
#3 0x00007ffff787787b in Jack::JackLockedEngine::Process (this=0x608180,
cur_cycle_begin=3218338954874, prev_cycle_end=1)
at ../common/JackLockedEngine.h:258
#4 0x00007ffff7876e62 in Jack::JackAudioDriver::ProcessGraphAsyncMaster (
this=0x6099b0) at ../common/JackAudioDriver.cpp:264
#5 0x00007ffff7876e19 in Jack::JackAudioDriver::ProcessGraphAsync (
this=0x6099b0) at ../common/JackAudioDriver.cpp:255
#6 0x00007ffff7876dde in Jack::JackAudioDriver::ProcessAsync (this=0x6099b0)
at ../common/JackAudioDriver.cpp:244
#7 0x00007ffff7876d57 in Jack::JackAudioDriver::Process (this=0x6099b0)
at ../common/JackAudioDriver.cpp:221
#8 0x00007ffff67b4ee2 in Jack::JackDummyDriver::Process (this=0x6099b0)
at ../common/JackDummyDriver.h:48
#9 0x00007ffff7887095 in Jack::JackThreadedDriver::Process (this=0x6176e0)
at ../common/JackThreadedDriver.cpp:73
#10 0x00007ffff7887719 in Jack::JackThreadedDriver::Execute (this=0x6176e0)
at ../common/JackThreadedDriver.cpp:246
#11 0x00007ffff78734f0 in Jack::JackPosixThread::ThreadHandler (arg=0x6176f8)
at ../posix/JackPosixThread.cpp:59
#12 0x00007ffff75e8b50 in start_thread ()
from /lib/x86_64-linux-gnu/libpthread.so.0
#13 0x00007ffff6a8f90d in clone () from /lib/x86_64-linux-gnu/libc.so.6
#14 0x0000000000000000 in ?? ()
(gdb) p fRollingClientUsecsIndex
$1 = -1610612736

I can paper around this, but this might not be the real culprit:

diff --git a/common/JackEngineControl.cpp b/common/JackEngineControl.cpp
index 4af6f68..2ab3323 100644
--- a/common/JackEngineControl.cpp
+++ b/common/JackEngineControl.cpp
@@ -53,6 +53,8 @@ void JackEngineControl::CalcCPULoad(JackClientInterface** table,
}

// Store the execution time for later averaging
+ if (fRollingClientUsecsIndex >= JACK_ENGINE_ROLLING_COUNT || fRollingClientUsecsIndex < 0)
+ fRollingClientUsecsIndex = 0;
if (last_cycle_end > 0)
fRollingClientUsecs[fRollingClientUsecsIndex++] = last_cycle_end - fPrevCycleTime;
if (fRollingClientUsecsIndex >= JACK_ENGINE_ROLLING_COUNT)