@Christian-Ehrlicher said in Segfault when calling QWidget::show (on Debian 9):
so is argc a local variable? If so then you have a dangling reference because Q(Core)Application takes a reference of argc and the documentation clearly states: Warning: The data referred to by argc and argv must stay valid for the entire lifetime of the QCoreApplication object. In addition, argc must be greater than zero and argv must contain at least one valid character string.
Already told you this 13 days ago btw.
Finally! Yesterday the issue got fixed! The problem was indeed what @Christian-Ehrlicher hinted at (for which thanks!):
We have an mfInitialize function in which we create an object of type ICBlackBoxBaseApplication which subclasses QApplication and also takes argc by int& instead of by int.
bool ICBlackBoxBase::mfInitialize(int argc, char **argv, QString& errormsg)
{
.... some stuff ...
mpApplication = new ICBlackBoxBaseApplication(argc, argv, this);
... other stuff ...
}
and indeed, for as far as I understand this bug, once the mfInitialize function has returned, the ICBlackBoxBaseApplication thus has a dangling reference to the (meanwhile disappeared) argc variable, which was probably causing the segfault.
Passing argc by reference instead of by value
bool ICBlackBoxBase::mfInitialize(int& argc, char **argv, QString& errormsg)
solved the problem.
Again many thanks to all in this thread who helped me think about this issue and work towards a solution. Especially @Christian-Ehrlicher (although I had the impression he was sometimes annoyed by my questions ;-) Note also that it took me more than 13 days to solve this, because there was Christmas holidays in between ;-)