Detect valgrind, avoid database removal when using valgrind
ClosedPublic

Authored by bruns on Jun 4 2019, 4:09 PM.

Details

Summary

The mmap size supported by valgrind is set at valgrind compile time. If
the application tries to mmap in total more than the supported size,
the mmap fails. As a result lmdb fails to open the DB which is
interpreted as a broken DB, thus the DB is deleted.

Valgrind can be detected at runtime using the RUNNING_ON_VALGRIND
macro from valgrind.h, which is added to the sources:

You are encouraged to copy the valgrind/*.h headers into your project's
include directory, so your program doesn't have a compile-time
dependency on Valgrind being installed. The Valgrind headers, unlike
most of the rest of the code, are under a BSD-style license so you may
include them without worrying about license incompatibility.

Test Plan

valgrind --tool=callgrind baloo_file

org.kde.baloo.engine: Valgrind detected, limiting DB mmap to 40 GByte

Diff Detail

Repository
R293 Baloo
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
bruns created this revision.Jun 4 2019, 4:09 PM
Restricted Application added projects: Frameworks, Baloo. · View Herald TranscriptJun 4 2019, 4:09 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
bruns requested review of this revision.Jun 4 2019, 4:09 PM
bruns edited the summary of this revision. (Show Details)Jun 4 2019, 4:09 PM
bruns updated this revision to Diff 59137.Jun 4 2019, 4:15 PM

rebase

mgallien accepted this revision.Jun 4 2019, 4:28 PM
mgallien added a subscriber: mgallien.

Very nice. Thank you

This revision is now accepted and ready to land.Jun 4 2019, 4:28 PM
ngraham accepted this revision.Jun 4 2019, 4:31 PM

Hah, wow

This revision was automatically updated to reflect the committed changes.

This changes breaks the build on Windows/MSVC because 'valgrind.h' doesn't support MSVC.
Can you please correct this / disable this check on Windows?