Bug 302421 - kooka crashes when trying OCR via gocr
Summary: kooka crashes when trying OCR via gocr
Status: RESOLVED FIXED
Alias: None
Product: kooka
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR crash
Target Milestone: ---
Assignee: Jonathan Marten
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-23 20:44 UTC by Johannes Obermayr
Modified: 2012-06-25 07:49 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch to fix (669 bytes, patch)
2012-06-24 16:30 UTC, Jonathan Marten
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Obermayr 2012-06-23 20:44:16 UTC
Application: kooka (0.61)
KDE Platform Version: 4.8.4 (4.8.4) "release 2"
Qt Version: 4.8.2
Operating System: Linux 3.4.3-1-desktop x86_64
Distribution: "openSUSE 12.1 (x86_64)"

-- Information about the crash:
Try to OCR with gocr; ocrad "works".

The crash can be reproduced every time.

-- Backtrace:
Application: Kooka (kooka), signal: Segmentation fault
[KCrash Handler]
#6  ref (this=0x30) at ../../src/corelib/arch/qatomic_x86_64.h:121
#7  QString (other=..., this=0x7ffff43a5ba0) at ../../src/corelib/tools/qstring.h:726
#8  QLocalePrivate::stringToLongLong (this=<optimized out>, number=..., base=10, ok=0x7ffff43a5d1f, group_sep_mode=QLocalePrivate::FailOnGroupSeparators) at tools/qlocale.cpp:2984
#9  0x00007fc131ca4692 in QString::toLongLong (this=0x332b020, ok=0x0, base=10) at tools/qstring.cpp:5593
#10 0x00007fc131ca47b9 in QString::toInt (this=<optimized out>, ok=0x0, base=<optimized out>) at tools/qstring.cpp:5731
#11 0x000000000044d0a9 in OcrGocrEngine::slotGOcrStdout (this=0x3085340) at /usr/src/debug/kooka-0.61_git.1330768816/kooka/ocrgocrengine.cpp:267
#12 0x000000000044d22a in OcrGocrEngine::slotGOcrExited (this=0x3085340, exitCode=0, exitStatus=<optimized out>) at /usr/src/debug/kooka-0.61_git.1330768816/kooka/ocrgocrengine.cpp:147
#13 0x00007fc131d6ec41 in QMetaObject::activate (sender=0x3086ab0, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7ffff43a60e0) at kernel/qobject.cpp:3556
#14 0x00007fc131cf031f in QProcess::finished (this=<optimized out>, _t1=0, _t2=QProcess::NormalExit) at .moc/release-shared/moc_qprocess.cpp:156
#15 0x00007fc131cf7996 in QProcessPrivate::_q_processDied (this=0x2f809b0) at io/qprocess.cpp:1068
#16 0x00007fc131cf7a1e in qt_static_metacall (_a=<optimized out>, _id=<optimized out>, _o=<optimized out>, _c=<optimized out>) at .moc/release-shared/moc_qprocess.cpp:92
#17 QProcess::qt_static_metacall (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at .moc/release-shared/moc_qprocess.cpp:69
#18 0x00007fc131d6ec41 in QMetaObject::activate (sender=0x3076b80, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7ffff43a62a0) at kernel/qobject.cpp:3556
#19 0x00007fc131dbc30e in QSocketNotifier::activated (this=<optimized out>, _t1=26) at .moc/release-shared/moc_qsocketnotifier.cpp:103
#20 0x00007fc131d77fcb in QSocketNotifier::event (this=0x3076b80, e=0x7ffff43a6910) at kernel/qsocketnotifier.cpp:317
#21 0x00007fc130ec0fe4 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib64/libQtGui.so.4
#22 0x00007fc130ec5db3 in QApplication::notify(QObject*, QEvent*) () from /usr/lib64/libQtGui.so.4
#23 0x00007fc1331b6746 in KApplication::notify(QObject*, QEvent*) () from /usr/lib64/libkdeui.so.5
#24 0x00007fc131d5ad0c in QCoreApplication::notifyInternal (this=0x7ffff43a6bc0, receiver=0x3076b80, event=0x7ffff43a6910) at kernel/qcoreapplication.cpp:915
#25 0x00007fc131d89427 in sendEvent (event=0x7ffff43a6910, receiver=<optimized out>) at kernel/qcoreapplication.h:231
#26 socketNotifierSourceDispatch (source=0x237bd10) at kernel/qeventdispatcher_glib.cpp:110
#27 0x00007fc12bc8358d in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#28 0x00007fc12bc83d88 in ?? () from /usr/lib64/libglib-2.0.so.0
#29 0x00007fc12bc83f59 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#30 0x00007fc131d89dcf in QEventDispatcherGlib::processEvents (this=0x2357060, flags=<optimized out>) at kernel/qeventdispatcher_glib.cpp:424
#31 0x00007fc130f6469e in ?? () from /usr/lib64/libQtGui.so.4
#32 0x00007fc131d59842 in QEventLoop::processEvents (this=<optimized out>, flags=...) at kernel/qeventloop.cpp:149
#33 0x00007fc131d59a97 in QEventLoop::exec (this=0x7ffff43a6b50, flags=...) at kernel/qeventloop.cpp:204
#34 0x00007fc131d5e8b5 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1187
#35 0x0000000000422cd7 in main (argc=3, argv=0x7ffff43a7038) at /usr/src/debug/kooka-0.61_git.1330768816/kooka/main.cpp:131

Possible duplicates by query: bug 256133.

Reported using DrKonqi
Comment 1 Jonathan Marten 2012-06-24 16:30:36 UTC
Created attachment 72096 [details]
Patch to fix

Thanks for the report.  Have spotted a very suspicious use of QStringList (via QRegExp) in the GOCR progress detection; this was unlikely to have been triggered before because GOCR doesn't actually seem to output any progress information, contrary to its man page.  However, if the OCR result text happens to match the pattern "<startofline><whitespace><number><whitespace><number>" on any line, the crash may happen - either an assert or a crash, depending on whether Qt is compiled in debug or release mode.

Can you compile Kooka from source?  If so, can you try it with the patch attached on the same OCR input and let me know if this fixes the problem.  See http://techbase.kde.org/Projects/Kooka for build instructions (get the latest Git version, then apply the patch on top of it).
Comment 2 Johannes Obermayr 2012-06-24 19:00:56 UTC
The patch works. Thanks.
Comment 3 Jonathan Marten 2012-06-25 07:49:13 UTC
Git commit d7238d569de8d64205ad991d142b9135322fd5c6 by Jonathan Marten.
Committed on 25/06/2012 at 09:37.
Pushed by marten into branch 'master'.

Fix crash with GOCR: suspicous use of QRegExp::capturedTexts()
with a pattern that doesn't have any capture sections defined!

Rewrite the GOCR stdout/stderr handling for better separation
of results, progress and error/debug.

GOCR result text is sent to a temporary file (formerly stdout)
and read when the OCR process is finished.

GOCR standard error is sent to another file (formerly printed via
kDebug(), but nothing else was done with it).

GOCR progress is still sent to stdout - the only thing that should
now be sent to stdout - and used to display progress.  Only really
useful for very long OCR tasks, since GOCR only prints progress
messages at 10 second intervals.

Correct the capture and handling of the GOCR progress output,
and the scanning of the progress line.  Pointless, because nothing
currently uses the progress signal!

Fixed initial value setting problem with KScanSlider which showed
itself in the GOCR setup dialogue page.

M  +105  -59   kooka/ocrgocrengine.cpp
M  +3    -2    kooka/ocrgocrengine.h
M  +1    -1    libkscan/kscancontrols.cpp

http://commits.kde.org/kooka/d7238d569de8d64205ad991d142b9135322fd5c6