You are here

segmentation fault when closing with VST plugins open

Hi,

First off thanks for a great piece of software. I've noticed that the program segfaults on exit when VST plugins have their editor open, for example with the Aspect VST. It looks like this is because of multipe calls to closeEditor, the patch below appears to fix the problem, but I don't know if that is the "right" way to solve it.
Another weird exit-effect is that sometimes the program never exits, but gets stuck waiting on the qtractorAudioPeakFile::m_mutex, not sure what causes that...

--- qtractor-svn-update/src/qtractorVstPlugin.h	2014-07-31 06:48:58.231330252 +0200
+++ qtractor/src/qtractorVstPlugin.h	2014-08-04 18:46:03.576215203 +0200
@@ -172,6 +172,7 @@
 	// Parameter update method.
 	void updateParamValues(bool bUpdate);
 
+	bool closingEditor() { return m_closing_editor; }
 private:
 
 	// Instance variables.
@@ -183,6 +184,8 @@
 
 	// Our own editor widget (parent frame).
 	EditorWidget *m_pEditorWidget;
+
+	bool m_closing_editor;
 };
 
--- qtractor-svn-update/src/qtractorVstPlugin.cpp	2014-07-31 06:48:58.223330253 +0200
+++ qtractor/src/qtractorVstPlugin.cpp	2014-08-04 18:38:16.076226369 +0200
@@ -276,7 +276,7 @@
 
 		QWidget::closeEvent(pCloseEvent);
 
-		if (m_pVstPlugin)
+		if (m_pVstPlugin && !m_pVstPlugin->closingEditor())
 			m_pVstPlugin->closeEditor();
 	}
 
@@ -581,7 +581,7 @@
 qtractorVstPlugin::qtractorVstPlugin ( qtractorPluginList *pList,
 	qtractorVstPluginType *pVstType )
 	: qtractorPlugin(pList, pVstType), m_ppEffects(NULL),
-		m_ppIBuffer(NULL), m_ppOBuffer(NULL), m_pEditorWidget(NULL)
+		m_ppIBuffer(NULL), m_ppOBuffer(NULL), m_pEditorWidget(NULL), m_closing_editor(false)
 {
 #ifdef CONFIG_DEBUG
 	qDebug("qtractorVstPlugin[%p] filename=\"%s\" index=%lu typeHint=%d",
@@ -1005,6 +1005,7 @@
 // Close editor.
 void qtractorVstPlugin::closeEditor (void)
 {
+	m_closing_editor = true;
 	if (m_pEditorWidget == NULL)
 		return;
 
Forums: 
rncbc's picture

patch applied, simplified and brainlessly re-styled :)

svn trunk r3962 aka. qtractor v0.6.2.3.

test && tell.
thanks

ps. re. program never exits, but gets stuck waiting on the qtractorAudioPeakFile::m_mutex... try getting rid of any .peak files out there; they might just be leftovers of previous crashes/segfaults.

byee

That seems to solve the segfault, thanks!
Still gets stuck on the mutex while exiting sometimes, but that might be due to having an unreasonably large FLAC file open in the session (8 hours...), or maybe because of my hacked PulseAudio audioengine backend..I'll investigate a bit more.

Found the cause of the exit delay, if the peak thread tries a setRunState(0) in its destructor while writing a peak file, the thread doesn't stop until it is done writing, which takes a while with my 8 hour file :o)

rncbc's picture

ok. nailed it.

please test whether svn trunk r3964 aka. qtractor v0.6.2.5, behaves any better on that regard.

cheers.

Still seems to get stuck with this version..however it does exit immediately now if I add this dirty hack:

 while (m_bRunState && writePeakFile()) {
    m_mutex.unlock(); this->sleep(0); m_mutex.lock(); // give setRunState a chance to run
}

Thanks!

rncbc's picture

you're right of course--i've nailed it again by dropping the mutex-locker on setRunState() instead.

svn trunk r3966 aka. qtractor v0.6.2.7

please test && tell, again ;)
cheers

works fine now!

Add new comment