Bug 96535 - Code obfuscation results in memory leaks reported by Valgrind, AddressSanitizer
Summary: Code obfuscation results in memory leaks reported by Valgrind, AddressSanitizer
Status: RESOLVED MOVED
Alias: None
Product: fontconfig
Classification: Unclassified
Component: library (show other bugs)
Version: 2.11
Hardware: Other All
: medium normal
Assignee: fontconfig-bugs
QA Contact: Behdad Esfahbod
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-15 10:28 UTC by Zoltán Böszörményi
Modified: 2018-08-20 21:50 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Zoltán Böszörményi 2016-06-15 10:28:26 UTC
Fontconfig uses pointer arithmetics to compute the distance from an object base pointer to a member structure and the result is stored in intptr_t type members.

This causes reported memory leaks in fontconfig in applications compiled with GCC's AddressSanitizer and Valgrind, too.

The fact that the size of intptr_t always equals to the size of a pointer makes this whole thing look like code obfuscation.

It also slows down the code slightly. Pointer arithmetics and storing the result is always slower than just storing the pointer value.

The amount of reported memory leaks in AddressSanitizer is so much that it makes genuine debugging hard, like searching for a needle in a haystack.

Please, use real pointers instead of intptr_t.
Comment 1 Behdad Esfahbod 2016-06-15 10:45:48 UTC
This definitely was not done for obfuscation purposes, but to make the caches relocatable while maintaining existing public API.  So, unfortunately, that cannot change until fontconfig 3.  For valgrind, there's a suppression file on the web.  For AddressSanitizer I don't know if something like that is possible.
Comment 2 milasudril 2017-04-20 10:04:27 UTC
(In reply to Behdad Esfahbod from comment #1)
> This definitely was not done for obfuscation purposes, but to make the
> caches relocatable while maintaining existing public API.  So,
> unfortunately, that cannot change until fontconfig 3.  For valgrind, there's
> a suppression file on the web.  For AddressSanitizer I don't know if
> something like that is possible.

Where?
Comment 3 Behdad Esfahbod 2017-04-20 18:38:22 UTC
For example:
https://gist.github.com/bert/758760

Maybe we should clean up some of that and ship it.  I don't think all marked there are correct.
Comment 4 GitLab Migration User 2018-08-20 21:50:27 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/77.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.