rhboot / rhboot/pesign

Compilation error with gcc 10, -Werror=array-bounds and -O2 or higher

Open
#63 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue
Dominant language
C
Stars
126
Forks
64
Avg merge
6d 15h
Merged PRs (30d)
3

Description

gcc -O2 -g -Wall -Werror=array-bounds  -Wall -Wextra -Wsign-compare -Wno-unused-result -Wno-unused-function -Wno-missing-field-initializers -Werror -Wno-error=cpp -std=gnu11 -fshort-wchar -fPIC -fno-strict-aliasing -D_GNU_SOURCE -DCONFIG_x86_64 -I/home/stefan/projects/pesign/include   -Wmaybe-uninitialized -grecord-gcc-switches -flto     -fno-merge-constants -fvar-tracking -fvar-tracking-assignments -fkeep-inline-functions -Wl,--fatal-warnings,--no-allow-shlib-undefined,--default-symver -Wl,-O2 -Wl,--no-undefined-version -Wl,-z,relro,-z,now -Wl,--no-add-needed,--no-copy-dt-needed-entries,--as-needed   -shared \
        -Wl,-soname,libdpe.so.0.113 \
        -o libdpe.so libdpe.o pe_addcert.o pe_allocspace.o pe_begin.o pe_end.o pe_error.o pe_getdatadir.o pe_getpehdr.o pe_getscn.o pe_getshdr.o pe_nextscn.o pe_opthdr.o pe_rawfile.o pe_readall.o
pe_update.o pe_updatefile.o pe_updatenull.o -lpthread
pe_begin.c: In function ‘read_file.constprop’:
common.h:107:11: error: array subscript 1 is outside array bounds of ‘union [1]’ [-Werror=array-bounds]
  107 |   switch (le16_to_cpu(peo->magic)) {
      |           ^
pe_begin.c:176:4: note: while referencing ‘mem’
  176 |  } mem;
      |    ^
lto1: all warnings being treated as errors
lto-wrapper: fatal error: gcc returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

See also: https://bugs.gentoo.org/721934
I have reproduced this error with the latest source from the master branch. It does not reproduce with gcc 9, or gcc 10 with -O{0,1}.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the build with GCC 10, -O2 or higher, and the flags shown in the report. Start at common.h:107 and pe_begin.c:176, then verify the build completes without the array-bounds warning treated as an error.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
build-system, compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.