Bug 72749 - crashes when printing, suspect calls of QFont::fromString()
Summary: crashes when printing, suspect calls of QFont::fromString()
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Compiled Sources Solaris
: NOR crash
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-16 12:16 UTC by Jonathan Marten
Modified: 2004-01-20 20:20 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Guard against Qt font setting crash (in 2 places) (668 bytes, patch)
2004-01-16 12:18 UTC, Jonathan Marten
Details
output of strace when printing from kwrite (6.49 KB, text/plain)
2004-01-16 20:50 UTC, Simon Siemonsma
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Marten 2004-01-16 12:16:44 UTC
Version:            (using KDE KDE 3.1.94)
Installed from:    Compiled From Sources
Compiler:          GCC 3.2.1 
OS:          Solaris

Kate or its part embedded in anything else (Konqueror when previewing a text file, Kwrite, etc.)
crashes when attempting to print a plain text file.  The last part of the debug output, and the
backtrace, is:

kdeprint: kdeprint: status message: Generating print data: page 1
QFont::fromString: invalid description '
Program received signal SIGSEGV, Segmentation fault.
0xfd833474 in strlen () from /usr/lib/libc.so.1
(gdb) where
#0  0xfd833474 in strlen () from /usr/lib/libc.so.1
#1  0xfd885798 in _doprnt () from /usr/lib/libc.so.1
#2  0xfd887550 in vfprintf () from /usr/lib/libc.so.1
#3  0xfe211138 in qWarning(char const*, ...) (msg=0xfd8bc000 "") at tools/qglobal.cpp:505
(gdb) 

(This is QT 3.2.3).

The crash appears to be in one of the two QFont::fromString() calls in kdelibs/kate/part/kateprinter.cpp.
It is being called with a null string because the option key "app-kate-hffont" is not defined - why that
is undefined is another problem, but Kate should be defensive.  Qt tries to print some debug output
in this case, but appears to use a null pointer and crashes.  (This only happens on Solaris - 58011 is
probably the same happening on Linux, but there is no crash in this case).  So it is really a Qt bug, but
again Kate should be defensive and not make bad calls to fromString().

This may be a duplicate also of 54165, which was resolved WORKSFORME.

The attached patch checks that the printer option (font name) is not null before calling the QFont
routine.  With this applied, there is no crash and Kate prints successfully.
Comment 1 Jonathan Marten 2004-01-16 12:18:42 UTC
Created attachment 4192 [details]
Guard against Qt font setting crash (in 2 places)
Comment 2 Simon Siemonsma 2004-01-16 20:48:51 UTC
Same on Gentoo linux.
qt 3.1 works fine.
I couldn't find the other bugreports referred to, so I add my comments to this one.

I attach the output of strace.
Comment 3 Simon Siemonsma 2004-01-16 20:50:20 UTC
Created attachment 4199 [details]
output of strace when printing from kwrite
Comment 4 Christoph Cullmann 2004-01-16 21:17:15 UTC
does the patch work for you too ? I have applied it to head btw., it won't do any harm even on fixed qt versions
Comment 5 Christoph Cullmann 2004-01-19 12:18:24 UTC
somebody still gets this probs after the fix ? if yes, not much time to fix and backport until kde 3.2 release, therefor please test ;)
Comment 6 Jonathan Marten 2004-01-19 12:29:40 UTC
Not sure who is being asked if the patch works, but there are no problems for me after applying
the fix.

Many thanks for applying the fix so quickly, especially at this critical time for the 3.2 release!
Comment 7 Christoph Cullmann 2004-01-20 20:20:36 UTC
will close it, if it comes again up we will take care again ;)