Bug 18465 - memusagestat is built using system C library
Summary: memusagestat is built using system C library
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: malloc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: 2.30
Assignee: Florian Weimer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-30 18:10 UTC by Mike Frysinger
Modified: 2019-07-02 14:52 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Frysinger 2015-05-30 18:10:42 UTC
the memusagestat binary is not linked against the local copy of glibc.  instead it relies on whatever is installed.

for example:
$ cd .../glibc
$ export objdir=$PWD/build/x86_64
$ rm $objdir/memusagestat
$ cd malloc
$ make
gcc   -o /usr/local/src/gnu/glibc/build/x86_64/malloc/memusagestat /usr/local/src/gnu/glibc/build/x86_64/malloc/memusagestat.o  -lgd -lpng -lz -lm
Comment 2 Sourceware Commits 2019-04-24 11:58:28 UTC
The master branch has been updated by Florian Weimer <fw@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f9b645b4b0a10c43753296ce3fa40053fa44606a

commit f9b645b4b0a10c43753296ce3fa40053fa44606a
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Wed Apr 24 13:32:22 2019 +0200

    memusagestat: use local glibc when linking [BZ #18465]
    
    The memusagestat is the only binary that has its own link line which
    causes it to be linked against the existing installed C library.  It
    has been this way since it was originally committed in 1999, but I
    don't see any reason as to why.  Since we want all the programs we
    build locally to be against the new copy of glibc, change the build
    to be like all other programs.
Comment 3 Florian Weimer 2019-04-24 11:58:40 UTC
Fixed for glibc 2.30.
Comment 4 Sourceware Commits 2019-04-24 17:30:14 UTC
The release/2.29/master branch has been updated by Florian Weimer <fw@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=42dfc13abf6fbb4c7a0215238eb636b7d374e0e0

commit 42dfc13abf6fbb4c7a0215238eb636b7d374e0e0
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Wed Apr 24 19:07:46 2019 +0200

    memusagestat: use local glibc when linking [BZ #18465]
    
    The memusagestat is the only binary that has its own link line which
    causes it to be linked against the existing installed C library.  It
    has been this way since it was originally committed in 1999, but I
    don't see any reason as to why.  Since we want all the programs we
    build locally to be against the new copy of glibc, change the build
    to be like all other programs.
    
    (cherry picked from commit f9b645b4b0a10c43753296ce3fa40053fa44606a)
Comment 5 Sourceware Commits 2019-04-24 17:57:48 UTC
The release/2.28/master branch has been updated by Florian Weimer <fw@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=630d7201ceb12f8dcdbe20abce67e1333c5e15ee

commit 630d7201ceb12f8dcdbe20abce67e1333c5e15ee
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Wed Apr 24 19:30:53 2019 +0200

    memusagestat: use local glibc when linking [BZ #18465]
    
    The memusagestat is the only binary that has its own link line which
    causes it to be linked against the existing installed C library.  It
    has been this way since it was originally committed in 1999, but I
    don't see any reason as to why.  Since we want all the programs we
    build locally to be against the new copy of glibc, change the build
    to be like all other programs.
    
    (cherry picked from commit f9b645b4b0a10c43753296ce3fa40053fa44606a)
Comment 6 Sourceware Commits 2019-04-26 05:37:51 UTC
The master branch has been updated by Florian Weimer <fw@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a8ff215e56050a907189e713fd449bcafe99ff6b

commit a8ff215e56050a907189e713fd449bcafe99ff6b
Author: Florian Weimer <fweimer@redhat.com>
Date:   Fri Apr 26 07:16:30 2019 +0200

    Makeconfig: Move -Wl,-rpath-link options before library references
    
    Previously, the -Wl,-rpath-link options came after the libraries
    injected using LDLIBS-* variables on the link editor command line for
    main programs.  As a result, it could happen that installed libraries
    that reference glibc libraries used the installed glibc from the system
    directories, instead of the glibc from the build tree.  This can lead to
    link failures if the wrong version of libpthread.so.0 is used, for
    instance, due to differences in the internal GLIBC_PRIVATE interfaces,
    as seen with memusagestat and -lgd after commit
    f9b645b4b0a10c43753296ce3fa40053fa44606a ("memusagestat: use local glibc
    when linking [BZ #18465]").
    
    The isolation is necessarily imperfect because these installed
    libraries are linked against the installed glibc in the system
    directories.  However, in most cases, the built glibc will be newer
    than the installed glibc, and this link is permitted because of the
    ABI backwards compatibility glibc provides.
Comment 7 Sourceware Commits 2019-04-26 06:34:14 UTC
The release/2.29/master branch has been updated by Florian Weimer <fw@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0744a268bc73e42b14b83e4cf3d083c6df6344e8

commit 0744a268bc73e42b14b83e4cf3d083c6df6344e8
Author: Florian Weimer <fweimer@redhat.com>
Date:   Thu Apr 25 14:58:13 2019 +0200

    Revert "memusagestat: use local glibc when linking [BZ #18465]"
    
    This reverts commit 42dfc13abf6fbb4c7a0215238eb636b7d374e0e0.
    
    The position of the -Wl,-rpath-link= options on the linker command
    line is not correct, so the new way of linking memusagestat does not
    always work.
Comment 8 Sourceware Commits 2019-04-26 06:34:30 UTC
The release/2.28/master branch has been updated by Florian Weimer <fw@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9b3aac586964f7aee071aa25fef86d53b05d16b2

commit 9b3aac586964f7aee071aa25fef86d53b05d16b2
Author: Florian Weimer <fweimer@redhat.com>
Date:   Thu Apr 25 14:59:42 2019 +0200

    Revert "memusagestat: use local glibc when linking [BZ #18465]"
    
    This reverts commit 630d7201ceb12f8dcdbe20abce67e1333c5e15ee.
    
    The position of the -Wl,-rpath-link= options on the linker command
    line is not correct, so the new way of linking memusagestat does not
    always work.
Comment 9 Florian Weimer 2019-07-02 14:52:13 UTC
This commit is also recommended:

commit 27cec9aed97447dff887a88f4241604fffd8c525
Author: Florian Weimer <fweimer@redhat.com>
Date:   Tue Jul 2 16:45:52 2019 +0200

    malloc: Add nptl, htl dependency for the subdirectory [BZ #24757]
    
    memusagestat may indirectly link against libpthread.  The built
    libpthread should be used, but that is only possible if it has been
    built before the malloc programs.