Bug 373069 - memcheck/tests/leak_cpp_interior fails with GCC 5.1+
Summary: memcheck/tests/leak_cpp_interior fails with GCC 5.1+
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-29 10:47 UTC by Aleksandar Rikalo
Modified: 2018-09-10 10:09 UTC (History)
2 users (show)

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


Attachments
Turn off CXX11_ABI (2.94 KB, patch)
2016-11-29 10:53 UTC, Aleksandar Rikalo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aleksandar Rikalo 2016-11-29 10:47:39 UTC
Memcheck's leak_cpp_interior test has purpose to test heuristics for detecting some common cases, where the pointer is pointing in the middle of the block, but the chunk is not lost. One of such cases is old implementation of string that has format:

                                         [_Rep] 
*                                        _M_length 
*   [basic_string<char_type>]            _M_capacity 
*   _M_dataplus                          _M_refcount 
*   _M_p ---------------->               unnamed array of char_type

New library ABI introduced in GCC 5.1 includes new implementation of std::string. In new implementation pointer is no longer displaced from the beginning of the chunk. This causes failing of leak_cpp_interior test.

From GCC version 5.1.0, allocation of exceptions in libstdc++ is changed. Before GCC version 5.1.0 emergency buffer was statically allocated. In version 5.1.0 it is swapped with object of class poll with dynamically allocated arena. This change also causes failing of leak_cpp_interior test. Memcheck detects dynamically allocated block of 72,704 bytes for 64bit architectures or 18,688 bytes for 32bit architectures, that is not visible when using older versions of libstdc++.
Comment 1 Ivo Raisr 2016-11-29 10:52:09 UTC
I cannot comment anything about std::string implementation.
However for your second query have a look at bug:
https://bugs.kde.org/show_bug.cgi?id=345307
Comment 2 Aleksandar Rikalo 2016-11-29 10:53:53 UTC
Created attachment 102518 [details]
Turn off CXX11_ABI

This patch forces leak_cpp_interior to be compiled using old implementation of std::string.
Comment 3 Aleksandar Rikalo 2016-11-29 11:01:56 UTC
(In reply to Ivo Raisr from comment #1)
> I cannot comment anything about std::string implementation.
> However for your second query have a look at bug:
> https://bugs.kde.org/show_bug.cgi?id=345307

Thank You for quick response.
I've suggested patch for the first problem.
Comment 4 Petar Jovanovic 2017-01-31 13:36:26 UTC
(In reply to Aleksandar Rikalo from comment #2)
> Created attachment 102518 [details]
> Turn off CXX11_ABI
> 
> This patch forces leak_cpp_interior to be compiled using old implementation
> of std::string.

This patch looks fine by me. If no one objects, I will commit it later
today.
Comment 5 Petar Jovanovic 2017-01-31 18:24:40 UTC
(In reply to Aleksandar Rikalo from comment #2)
> Created attachment 102518 [details]
> Turn off CXX11_ABI
> 
> This patch forces leak_cpp_interior to be compiled using old implementation
> of std::string.

Patch submitted in r16217.

We should leave the bug open, as the original issue (closely related to
#345307) is still valid.
Comment 6 Petar Jovanovic 2018-09-10 10:09:09 UTC
Closing this as (partially) fixed.
For the remaining part of the problem, check https://bugs.kde.org/show_bug.cgi?id=345307.