Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 903259 - x11-libs/pango-1.50.14 fails with GCC 13 (13.0.1_pre20230326)
Summary: x11-libs/pango-1.50.14 fails with GCC 13 (13.0.1_pre20230326)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Linux Gnome Desktop Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: gcc-13
  Show dependency tree
 
Reported: 2023-03-28 02:01 UTC by Adrien Dessemond
Modified: 2023-04-26 02:21 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adrien Dessemond 2023-03-28 02:01:02 UTC
The compilation stops here:

(...)
[24/147] x86_64-pc-linux-gnu-gcc -m32 -mfpmath=sse -Ipango/libpango-1.0.so.0.5000.14.p -Ipango -I../pango-1.50.14/pango -I. -I../pango-1.50.14 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/libpng16 -I/usr/include/pixman-1 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=gnu99 -D_POSIX_C_SOURCE=200809L -D_POSIX_THREAD_SAFE_FUNCTIONS -D_GNU_SOURCE -O3 -pipe -march=native -fomit-frame-pointer -fopt-info-vec -fcf-protection=return -flto=auto -ffat-lto-objects -DG_DISABLE_CAST_CHECKS -fPIC -pthread -Wno-missing-include-dirs -Wduplicated-branches -Wduplicated-cond -Wformat=2 -Wformat-nonliteral -Wformat-security -Wignored-qualifiers -Wimplicit-function-declaration -Wlogical-op -Wmisleading-indentation -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wshadow -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wuninitialized -Wunused -Werror=address -Werror=array-bounds -Werror=empty-body -Werror=implicit -Werror=implicit-fallthrough -Werror=init-self -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=missing-declarations -Werror=missing-prototypes -Werror=nonnull -Werror=pointer-to-int-cast -Werror=redundant-decls -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=vla -Werror=write-strings -fno-strict-aliasing -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wformat-nonliteral -Wformat-security -Wunused -Wcast-align -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-include-dirs -Wlogical-op -Wno-uninitialized -Wno-shadow -Werror=implicit-fallthrough -Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-point -Werror=return-type -Werror=trigraphs -Werror=array-bounds -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast -Werror=empty-body -Werror=write-strings -Werror=unused-but-set-variable -Wundef -Werror=redundant-decls -fvisibility=hidden '-DG_LOG_DOMAIN="Pango"' -DG_LOG_USE_STRUCTURED=1 -DPANGO_COMPILATION '-DSYSCONFDIR="/etc"' '-DLIBDIR="/usr/lib"' -MD -MQ pango/libpango-1.0.so.0.5000.14.p/pango-language.c.o -MF pango/libpango-1.0.so.0.5000.14.p/pango-language.c.o.d -o pango/libpango-1.0.so.0.5000.14.p/pango-language.c.o -c ../pango-1.50.14/pango/pango-language.c
FAILED: pango/libpango-1.0.so.0.5000.14.p/pango-language.c.o 
x86_64-pc-linux-gnu-gcc -m32 -mfpmath=sse -Ipango/libpango-1.0.so.0.5000.14.p -Ipango -I../pango-1.50.14/pango -I. -I../pango-1.50.14 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/libpng16 -I/usr/include/pixman-1 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=gnu99 -D_POSIX_C_SOURCE=200809L -D_POSIX_THREAD_SAFE_FUNCTIONS -D_GNU_SOURCE -O3 -pipe -march=native -fomit-frame-pointer -fopt-info-vec -fcf-protection=return -flto=auto -ffat-lto-objects -DG_DISABLE_CAST_CHECKS -fPIC -pthread -Wno-missing-include-dirs -Wduplicated-branches -Wduplicated-cond -Wformat=2 -Wformat-nonliteral -Wformat-security -Wignored-qualifiers -Wimplicit-function-declaration -Wlogical-op -Wmisleading-indentation -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wshadow -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wuninitialized -Wunused -Werror=address -Werror=array-bounds -Werror=empty-body -Werror=implicit -Werror=implicit-fallthrough -Werror=init-self -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=missing-declarations -Werror=missing-prototypes -Werror=nonnull -Werror=pointer-to-int-cast -Werror=redundant-decls -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=vla -Werror=write-strings -fno-strict-aliasing -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wformat-nonliteral -Wformat-security -Wunused -Wcast-align -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-include-dirs -Wlogical-op -Wno-uninitialized -Wno-shadow -Werror=implicit-fallthrough -Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-point -Werror=return-type -Werror=trigraphs -Werror=array-bounds -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast -Werror=empty-body -Werror=write-strings -Werror=unused-but-set-variable -Wundef -Werror=redundant-decls -fvisibility=hidden '-DG_LOG_DOMAIN="Pango"' -DG_LOG_USE_STRUCTURED=1 -DPANGO_COMPILATION '-DSYSCONFDIR="/etc"' '-DLIBDIR="/usr/lib"' -MD -MQ pango/libpango-1.0.so.0.5000.14.p/pango-language.c.o -MF pango/libpango-1.0.so.0.5000.14.p/pango-language.c.o.d -o pango/libpango-1.0.so.0.5000.14.p/pango-language.c.o -c ../pango-1.50.14/pango/pango-language.c
../pango-1.50.14/pango/pango-language.c:55:19: optimized: basic block part vectorized using 64 byte vectors
In function ‘find_best_lang_match_cached’,
    inlined from ‘find_best_lang_match_cached’ at ../pango-1.50.14/pango/pango-language.c:501:1,
    inlined from ‘pango_language_get_scripts’ at ../pango-1.50.14/pango/pango-language.c:661:21:
../pango-1.50.14/pango/pango-language.c:518:12: error: array subscript 0 is outside array bounds of ‘const void *[0:]’ [-Werror=array-bounds=]
  518 |     *cache = result;
      |     ~~~~~~~^~~~~~~~
In function ‘pango_language_get_scripts’:
cc1: note: source object is likely at address zero
cc1: some warnings being treated as errors


Full build log attached.
Package does not fail with GCC 12.
Comment 1 Adrien Dessemond 2023-03-28 18:16:04 UTC
1.50.14 is the latest release so far, so I am out of luck :)

An ugly workaround (to avoid some code refactoring hell) would be to put some "#pragma GCC diagnostic" directives around the function find_best_lang_match_cached() like this:

(...)

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"

static gconstpointer
find_best_lang_match_cached (PangoLanguage *language,
                             gconstpointer *cache,
                             gconstpointer  records,
                             guint          num_records,
                             guint          record_size)
{
  gconstpointer result;

  if (G_LIKELY (cache && *cache != (gconstpointer) -1))
    return *cache;

  result = find_best_lang_match (language,
                                 records,
                                 num_records,
                                 record_size);

  if (cache)
    *cache = result;

  return result;
}

#pragma GCC diagnostic pop

(...)

This function is used via a #define at only two places in the very same file: see functions pango_language_get_sample_string() and pango_language_get_scripts()

At both places, what find_best_lang_match_cached() returns is checked for a NULL value so I am quite confident that this trick will not break Pango.

(Not reported at upstream yet).
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-03-28 18:17:44 UTC
Please pop a link here when you do report upstream to Pango. Also a chance, as ever, that it's an FP, but it could easily be the compiler is better at analysis. Fun as always & thank you for testing gcc 13!
Comment 3 Adrien Dessemond 2023-04-03 21:14:17 UTC
Reported upstream, see the link in "See also".
Comment 4 Arsen Arsenović gentoo-dev 2023-04-19 01:35:18 UTC
can't reproduce on a checkout of 1.50.14 with

/tmp/pango$ gcc --version
gcc (Gentoo Hardened 13.0.1_pre20230409-r4 p9) 13.0.1 20230409 (experimental)
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


and CC=gcc CFLAGS="-O3 -pipe -march=native -fomit-frame-pointer -fopt-info-vec -fcf-protection=return -flto=auto"
Comment 5 Arsen Arsenović gentoo-dev 2023-04-19 01:37:26 UTC
oddly enough, can reproduce under portage
Comment 6 Larry the Git Cow gentoo-dev 2023-04-26 02:21:07 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f688df5100ef2b88c975ecd40fd343c62e2ab276

commit f688df5100ef2b88c975ecd40fd343c62e2ab276
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-04-26 02:10:54 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-04-26 02:10:54 +0000

    x11-libs/pango: workaround -Werror=array-bounds issue w/ GCC 13
    
    Seems to be a false positive. Reported upstream by Adrien at https://gitlab.gnome.org/GNOME/pango/-/issues/740.
    
    Happens w/ GCC 13 combined with -O3 at least but may happen for other
    combinations too. Can't append -Wno-error=... because of the order the flags
    are added, unfortunately.
    
    Closes: https://bugs.gentoo.org/903259
    Signed-off-by: Sam James <sam@gentoo.org>

 x11-libs/pango/pango-1.50.14.ebuild | 4 ++++
 1 file changed, 4 insertions(+)