libksane seems to break QProcess::start calls

Tobias Leupold tl at l3u.de
Fri Mar 4 18:52:00 GMT 2022


Hey Thiago,

Am Freitag, 4. März 2022, 18:35:23 CET schrieb Thiago Macieira:
> And this is the reason why you got the symptom of QProcess breaking. We'd
> have expected that the eight mention be the same as the fifth, to keep the
> pattern going, but it isn't. It's the same as the second and sixth
> mentions. The SIGCHLD handler that ran is that stupidly short one, which we
> now know to be definitely buggy.

Thanks a lot for the comprehensive analysis! I don't grasp this compleley -- 
or, to be honest, not at all ... most likely, one has to be a real programmer 
to do so ;-) But it's definitely quite impressive how you can read this from 
the trace!

But this:

Am Freitag, 4. März 2022, 18:02:37 CET schrieb Thiago Macieira:
> So the question is why this brscan didn't even attempt to use pidfd. There's
> some code in Qt5's QProcess to attempt to detect whether you've subclassed
> QProcess and skip using the pidfd feature:
> 
>     if (typeid(*q) != typeid(QProcess))
>         ffdflags |= FFD_USE_FORK;
> 
> https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/io/qprocess_unix.cpp?
> h=5.15#n462

made me try one thing:

I used a small helper class subclassing QProcess to execute the external 
commands. It did not much, just took a command line like you would type it in 
a shell, along with the in and out file, extracted the program parameter from 
it and assembled the arguments QStringList. And then ran QProcess::start and 
checked if the start succeeded, and catched STDERR if the program would not 
exit with 0.

I simply made this a QObject subclass and rather then using start() etc. 
directly, I created a QProcess object and did the same stuff with this one.

No freezes anymore. No matter what scanner I use.

I never thought subclassing the QProcess would change the behavior in such a 
radical way :-O Is there some passage in the docs that says "Never ever 
subclass a QProcess unless you exactly know what you are doing, otherwise, you 
will experience the weirdest problems"? :-D

I would never have figured this out. Thank you very very much for having a 
look at this and pointing me in the right direction.

Cheers, Tobias




More information about the kde-devel mailing list