Sorry to bump into this pretty old thread of mine. The reason is, the random crash is still happening. Even worst, now it's occasionally freezes.
The crash usually happens inside an SDL_Thread. The thread is for printing with LaTeX and CUPS while the main application does some sort of animation and progress bar. This is what's inside the thread's function:
int CMainApp::printNow(void *data)
/// @todo implement me
pMyApp->createTempLatex(); //Create temporary latex file
pMyApp->createTempPostScript(); //Create temporary postscript file
pMyApp->printPostScriptFile(); //Print with CUPS
The createTempLatex() is only a function that create a LaTeX file as an output like this:
filestr.open ("./temp-print.tex", fstream::out);
..... //The body of the LaTeX file
And inside the createTempPostScript() function there's 2 system calls for converting the Latex to a DVI file, and a DVI to PS file like this:
system("latex temp-print.tex -halt-on-error");
system("dvips temp-print -Pcmz -t landscape -o temp-print.ps");
And the printPostScriptFile() is for sending the PS file to the CUPS spooling queue for printing.
I don't know what's wrong with it but this thread function randomly generates crashes. Often it worked fine until few printings. But every now and then it will crash. And the crash is always in this printing routine.
The crash itself is not always a segmentation error. This is what usually
happen if the application crashed:
1. Back to terminal with segmentation error
2. Hangs up. The animation and progress bar are not working. The event
handler also not working. It's like the system freezes out.
3. Infinite loop. The event handler, animation, and progress bar are
working. But because the application needed the thread to finish before
going to the next state, it will stay inside the current state (printing
state). This always happens if the thread is still doing its stuffs in one
of the system calls yet SDL_WaitThread() has been called.
Can anybody give me some help here? How do you usually solve this kind of
problem? Thanks in advance.