Bug 353848

Summary: Baloo File Extractor crashes after startup
Product: [Frameworks and Libraries] frameworks-kfilemetadata Reporter: fab <mikuji>
Component: generalAssignee: Pinak Ahuja <pinak.ahuja>
Status: RESOLVED FIXED    
Severity: crash CC: aspotashev
Priority: NOR Keywords: drkonqi
Version: 5.14.0   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description fab 2015-10-13 06:56:57 UTC
Application: baloo_file_extractor (5.14.0)

Qt Version: 5.5.0
Operating System: Linux 4.1.8-200.fc22.x86_64 x86_64
Distribution: "Fedora release 22 (Twenty Two)"

-- Information about the crash:
- What I was doing when the application crashed:

Baloo File Extractor crashes after startup or waking up from sleep

-- Backtrace:
Application: Baloo File Extractor (baloo_file_extractor), signal: Segmentation fault
Using host libthread_db library "/lib64/libthread_db.so.1".
[KCrash Handler]
#5  0x00000031de0bf238 in Exiv2::ValueType<std::pair<unsigned int, unsigned int> >::toFloat(long) const () at /lib64/libexiv2.so.13
#6  0x00007fda3811c2e0 in (anonymous namespace)::toVariantDouble(Exiv2::Value const&) [clone .constprop.34] () at /usr/lib64/qt5/plugins/kf5/kfilemetadata/kfilemetadata_exiv2extractor.so
#7  0x00007fda3811dba0 in KFileMetaData::Exiv2Extractor::add(KFileMetaData::ExtractionResult*, Exiv2::ExifData const&, KFileMetaData::Property::Property, char const*, QVariant::Type) [clone .constprop.28] () at /usr/lib64/qt5/plugins/kf5/kfilemetadata/kfilemetadata_exiv2extractor.so
#8  0x00007fda3811e123 in KFileMetaData::Exiv2Extractor::extract(KFileMetaData::ExtractionResult*) () at /usr/lib64/qt5/plugins/kf5/kfilemetadata/kfilemetadata_exiv2extractor.so
#9  0x000000000040abf3 in Baloo::App::index(Baloo::Transaction*, QString const&, unsigned long long) ()
#10 0x000000000040b710 in Baloo::App::slotNewInput() ()
#11 0x00000031bf0b1fe7 in QMetaObject::activate(QObject*, int, int, void**) () at /lib64/libQt5Core.so.5
#12 0x00000031bf13166e in QSocketNotifier::activated(int, QSocketNotifier::QPrivateSignal) () at /lib64/libQt5Core.so.5
#13 0x00000031bf0be63b in QSocketNotifier::event(QEvent*) () at /lib64/libQt5Core.so.5
#14 0x00000031bf0835fc in QCoreApplication::notifyInternal(QObject*, QEvent*) () at /lib64/libQt5Core.so.5
#15 0x00000031bf0da25d in socketNotifierSourceDispatch(_GSource*, int (*)(void*), void*) () at /lib64/libQt5Core.so.5
#16 0x00000031ad249a8a in g_main_context_dispatch () at /lib64/libglib-2.0.so.0
#17 0x00000031ad249e20 in g_main_context_iterate.isra () at /lib64/libglib-2.0.so.0
#18 0x00000031ad249ecc in g_main_context_iteration () at /lib64/libglib-2.0.so.0
#19 0x00000031bf0d9dab in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /lib64/libQt5Core.so.5
#20 0x00000031bf080daa in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /lib64/libQt5Core.so.5
#21 0x00000031bf088e6c in QCoreApplication::exec() () at /lib64/libQt5Core.so.5
#22 0x000000000040a2e6 in main ()

Reported using DrKonqi
Comment 1 Igor Poboiko 2018-10-16 13:56:15 UTC
Git commit 5eee9ac75b7d6bb19795c2d3b964fe05fd8fc47c by Igor Poboiko.
Committed on 16/10/2018 at 13:56.
Pushed by poboiko into branch 'master'.

Don't crash on invalid exiv2 data

Summary:
The file from bug 375131 crashes `baloo_file_extractor`.
The problem is that its EXIF data contains a key `Exif.Photo.FocalLength`,
whose type is `Exiv2::unsignedRational`, and whose value is empty.
On the other hand, the `Exiv2::Value::toFloat()` call relies on at least single component of a value,
causing undefined behavior (i.e. crash) if there is none.

This is simple workaround: if we got a property with no value, just return an empty QVariant().
(unfortunately, didn't manage to reproduce the hang reported in the bug originally)
Related: bug 352856, bug 361259, bug 375131

Test Plan: `baloo_file_extractor` no longer crashes on the file, it processes the file and extracts all the necessary data

Reviewers: #baloo, #frameworks, astippich

Reviewed By: astippich

Subscribers: bruns, astippich, kde-frameworks-devel

Tags: #frameworks, #baloo

Differential Revision: https://phabricator.kde.org/D16165

M  +3    -0    src/extractors/exiv2extractor.cpp

https://commits.kde.org/kfilemetadata/5eee9ac75b7d6bb19795c2d3b964fe05fd8fc47c