Bug 989798 - tps-srpmtest fails when rebuilding devtoolset-2-elfutils under devtoolset
tps-srpmtest fails when rebuilding devtoolset-2-elfutils under devtoolset
Product: Red Hat Developer Toolset
Classification: Red Hat
Component: elfutils (Show other bugs)
DTS 2.0 RHEL 5
All Linux
unspecified Severity unspecified
: alpha
: 2.4
Assigned To: Petr Machata
Dagmar Prokopová
Depends On:
  Show dependency treegraph
Reported: 2013-07-29 21:20 EDT by Dagmar Prokopová
Modified: 2014-07-01 18:54 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: Wrong buffer length expression was passed to snprintf function. DTS version of GCC was able to caught this problem, and warned about it. Because the elfutils package is built with -Werror command line option, that warning was turned into a hard error. Consequence: Build of elfutils would fail. Fix: Pass correct buffer length to snprintf. Result: elfutils can be rebuilt.
Story Points: ---
Clone Of:
Last Closed: 2014-03-11 02:38:31 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Dagmar Prokopová 2013-07-29 21:20:26 EDT
Description of problem:
When running tps-srpmtest for devtoolset-2-elfutils under devtoolset, the rebuild of the source package fails with the following error:

nm.c: In function 'show_symbols_sysv':
nm.c:773:27: error: argument to 'sizeof' in '__builtin___snprintf_chk' call is the same expression as the destination; did you mean to provide an explicit length? [-Werror=sizeof-pointer-memaccess]
    snprintf (name, sizeof name, "[invalid sh_name %#" PRIx32 "]",
cc1: all warnings being treated as errors

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. install devtoolset-2
2. scl enable devtoolset-2 bash
3. run tps-srpmtest

Actual results:
tps-srpmtest fails due to error mentioned above

Expected results:
successful rebuild, no failures

Additional info:
This issue appears on both rhel5 and rhel6, on both architectures, i386 and x86_64.
Comment 2 Dagmar Prokopová 2013-07-30 07:09:18 EDT
A particular example of rebuild command used by tps-srpmtest is here:

rpmbuild --rebuild   --define "dist .el5" --define '_topdir /usr/src/redhat' --target=i386 --rcfile /tmp/tps_rpmrc_T18959:/usr/lib/rpm/rpmrc:/usr/lib/rpm/redhat/rpmrc /mnt/redhat/brewroot/packages/devtoolset-2-elfutils/0.155/7.el5/src/devtoolset-2-elfutils-0.155-7.el5.src.rpm
Comment 4 Mark Wielaard 2013-08-09 16:48:19 EDT
This issue was exposed by the latest gcc (included in DTS). The elfutils package in DTS is compiled with the system gcc which didn't detect this issue.

The upstream fix is:

commit 57bd66cabf6e6b9ecf622cdbf350804897a8df58
Author: Roland McGrath <roland@hack.frob.com>
Date:   Tue Dec 11 09:42:07 2012 -0800

    nm: Fix size passed to snprintf for invalid sh_name case.
    Signed-off-by: Roland McGrath <roland@hack.frob.com>

with the followup:

commit 7df3d2cd70932cd70515dbeb75e4db66fd27f192
Author: Mark Wielaard <mjw@redhat.com>
Date:   Tue Dec 11 22:27:05 2012 +0100

    Add missing semicolon in show_symbols_sysv
    Signed-off-by: Mark Wielaard <mjw@redhat.com>

patch against elfutils source:

diff --git a/src/nm.c b/src/nm.c
index f50da0b..7aae84b 100644
--- a/src/nm.c
+++ b/src/nm.c
@@ -769,8 +769,9 @@ show_symbols_sysv (Ebl *ebl, GElf_Word strndx, const char *fullname,
                               gelf_getshdr (scn, &shdr_mem)->sh_name);
       if (unlikely (name == NULL))
-         name = alloca (sizeof "[invalid sh_name 0x12345678]");
-         snprintf (name, sizeof name, "[invalid sh_name %#" PRIx32 "]",
+         const size_t bufsz = sizeof "[invalid sh_name 0x12345678]";
+         name = alloca (bufsz);
+         snprintf (name, bufsz, "[invalid sh_name %#" PRIx32 "]",
                    gelf_getshdr (scn, &shdr_mem)->sh_name);
       scnnames[elf_ndxscn (scn)] = name;
Comment 6 Dagmar Prokopová 2013-11-16 06:50:05 EST
Verified for devtoolset-2-elfutils-0.157-2.el5.
Comment 8 errata-xmlrpc 2014-03-11 02:38:31 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.