Exception in EditPlaybackContext::isPlaying

Hi,

Twice the last half hour I got a crash in the audio thread where it looks like the playbackContext is NULL (see strack trace below).

I guess that this has to do with me freeing the playbackContext as discussed in Pause Edit the other day.

te::freePlaybackContextIfNotRecording(edit->getTransport());

There is probably something I should have done or thought about but any hints are most welcome!

(lldb) bt
* thread #22, name = 'Built-in Output', stop reason = EXC_BAD_ACCESS (code=1, address=0x38)
    frame #0: 0x0000000100effb76 Gaudiamus`tracktion_graph::PlayHead::isPlaying() const [inlined] std::__1::__atomic_base<int, false>::load(this=0x0000000000000038, __m=memory_order_relaxed) const at atomic:929
    frame #1: 0x0000000100effb3f Gaudiamus`tracktion_graph::PlayHead::isPlaying(this=0x0000000000000000) const at tracktion_graph_PlayHead.h:257
  * frame #2: 0x0000000100f6d0d7 Gaudiamus`tracktion_engine::EditPlaybackContext::isPlaying(this=0x0000000103c4d230) const at tracktion_EditPlaybackContext.cpp:832
    frame #3: 0x000000010106fedd Gaudiamus`tracktion_engine::RetrospectiveRecordBuffer::syncToEdit(this=0x0000000103e0b170, edit=0x0000000105053e00, context=0x0000000103c4d230, streamTime=4188.8217686678463, numSamplesIn=512) at tracktion_WaveInputDevice.cpp:156
    frame #4: 0x0000000100f9d769 Gaudiamus`tracktion_engine::WaveInputDeviceInstance::acceptInputBuffer(this=0x0000000103c399c0, allChannels=0x0000604000276000, numChannels=2, numSamples=512, streamTime=4188.8217686678463, measurerToUpdate=0x0000000103f15050, retrospectiveBuffer=0x0000000103e0b170, addToRetrospective=true) at tracktion_WaveInputDevice.cpp:1033
    frame #5: 0x0000000100f35595 Gaudiamus`tracktion_engine::WaveInputDevice::consumeNextAudioBlock(this=0x0000000103f15020, allChannels=0x0000604000276000, numChannels=2, numSamples=512, streamTime=4188.8217686678463) at tracktion_WaveInputDevice.cpp:1477
    frame #6: 0x0000000100f62299 Gaudiamus`tracktion_engine::DeviceManager::audioDeviceIOCallback(this=0x0000000104087a00, inputChannelData=0x0000604000276000, numInputChannels=2, outputChannelData=0x00000001040a6800, totalNumOutputChannels=2, numSamples=512) at tracktion_DeviceManager.cpp:1079
    frame #7: 0x0000000100228126 Gaudiamus`juce::AudioDeviceManager::audioDeviceIOCallbackInt(this=0x0000000104087a58, inputChannelData=0x0000604000276000, numInputChannels=2, outputChannelData=0x0000604000275d00, numOutputChannels=2, numSamples=512) at juce_AudioDeviceManager.cpp:831
    frame #8: 0x00000001002330ef Gaudiamus`juce::AudioDeviceManager::CallbackHandler::audioDeviceIOCallback(this=0x0000604000257520, ins=0x0000604000276000, numIns=2, outs=0x0000604000275d00, numOuts=2, numSamples=512) at juce_AudioDeviceManager.cpp:54
    frame #9: 0x000000010024079f Gaudiamus`juce::CoreAudioClasses::AudioIODeviceCombiner::run(this=0x000000010484a800) at juce_mac_CoreAudio.cpp:1605
    frame #10: 0x00000001004f94c6 Gaudiamus`juce::Thread::threadEntryPoint(this=0x000000010484a800) at juce_Thread.cpp:96
    frame #11: 0x00000001004f9985 Gaudiamus`juce::juce_threadEntryPoint(userData=0x000000010484a800) at juce_Thread.cpp:118
    frame #12: 0x0000000100528ef6 Gaudiamus`juce::threadEntryProc(userData=0x000000010484a800) at juce_posix_SharedCode.h:850
    frame #13: 0x0000000103a4b665 libsystem_pthread.dylib`_pthread_body + 340
    frame #14: 0x0000000103a4b511 libsystem_pthread.dylib`_pthread_start + 377
    frame #15: 0x0000000103a4abfd libsystem_pthread.dylib`thread_start + 13

Ok thanks for the heads up. Looks like the WaveInputDeviceInstance isn’t being removed correctly. Should be a straightforward fix.

I’m away at the moment until Monday but will take a look ASAP.

Ok I think this should fix the crash but I can’t actually see how it would get in to this state?

It feels like if you’re freeing a context it should never get to the point in syncToEdit that calls in to the context. Let me know if you see a similar crash again, there might be different info in a new stack trace.

Thanks! I’ll let you know it if happens again!