Hi, my application now is experiencing some random crashes. And the crash
is usually 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
CMainApp pMyApp=static_cast<CMainApp>(data);
pMyApp->createTempLatex(); //Create temporary latex file
pMyApp->createTempPostScript(); //Create temporary postscript file
pMyApp->printPostScriptFile(); //Print with CUPS
return 1;
}
The createTempLatex() is only a function that create a LaTeX file as an
output like this:
void CMainApp::createTempLatex()
{
fstream filestr;
filestr.open ("./temp-print.tex", fstream::out);
fstream<<"\begin{document}"<<endl;
… //The body of the LaTeX file
fstream<<"\end{document}"<<endl;
filestr.close();
}
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:
void CMainApp::createTempPostScript()
{
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 printing. 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:
- Back to terminal with segmentation error
- Hangs up. The animation and progress bar are not working. The event
handler also not working. It’s like the system freezes out. - 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.
Fare thee well,
Bawenang R. P. P.----------------
ERROR: Brain not found. Please insert a new brain!
?Do nothing which is of no use.? - Miyamoto Musashi.
“I live for my dream. And my dream is to live my life to the fullest.”