Build issue: FTBFS on Fedora 38 #70

Closed
opened 2 years ago by Francois · 17 comments
Collaborator

Basic information

  • TDE version: R14.1.0
  • Distribution: Fedora 38
  • Hardware: amd64

Description

During TQT3 build, the compiler says "buffer overflow detected : terminated"
And the build is stopped.

Compiler information:

$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-13.1.1-20230426/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.1.1 20230426 (Red Hat 13.1.1-1) (GCC) 

Steps to reproduce

Build

Screenshots

g++ -c -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -pipe -fvisibility=hidden -fvisibility-inlines-hidden -fvisibility-inlines-hidden -I/usr/include/fontconfig -I/usr/include/pgsql -I/usr/include/pgsql/server -I/usr/include/mysql -I/usr/include/libpng16 -I/usr/include/tirpc -fno-exceptions -w -g -D_REENTRANT  -DQT_INTERNAL_NETWORK -DQT_INTERNAL_XML -DQT_TABLET_SUPPORT -DTQT_THREAD_SUPPORT -DQT_SHARED -I/tmp/BUILD.fc38.unknown/trinity-tqt3-14.1.0/mkspecs/linux-g++-64 -I. -I/usr/include/freetype2 -I/usr/include -I../../include -I/usr/X11R6/include -I.moc/debug-shared-mt/ -o .obj/debug-shared-mt/moc_topicchooserimpl.o .moc/debug-shared-mt/moc_topicchooserimpl.cpp
*** buffer overflow detected ***: terminated
make[2]: *** [Makefile:271: topicchooser.cpp] Aborted (core dumped)
make[2]: *** Deleting file 'topicchooser.cpp'

See attached file for detailed output.

<!-- This is a comment. Please fill in the required fields below. The comments provide instructions on how to do so. Note: You do not need to remove comments. --> ## Basic information - TDE version: R14.1.0 - Distribution: Fedora 38 - Hardware: amd64 <!-- Use SL/* labels to set the severity level. Please do not set a milestone. --> ## Description During TQT3 build, the compiler says "buffer overflow detected : terminated" And the build is stopped. Compiler information: ``` $ gcc -v Using built-in specs. COLLECT_GCC=/usr/bin/gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/13/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-13.1.1-20230426/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.1.1 20230426 (Red Hat 13.1.1-1) (GCC) ``` ## Steps to reproduce Build ## Screenshots ``` g++ -c -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -pipe -fvisibility=hidden -fvisibility-inlines-hidden -fvisibility-inlines-hidden -I/usr/include/fontconfig -I/usr/include/pgsql -I/usr/include/pgsql/server -I/usr/include/mysql -I/usr/include/libpng16 -I/usr/include/tirpc -fno-exceptions -w -g -D_REENTRANT -DQT_INTERNAL_NETWORK -DQT_INTERNAL_XML -DQT_TABLET_SUPPORT -DTQT_THREAD_SUPPORT -DQT_SHARED -I/tmp/BUILD.fc38.unknown/trinity-tqt3-14.1.0/mkspecs/linux-g++-64 -I. -I/usr/include/freetype2 -I/usr/include -I../../include -I/usr/X11R6/include -I.moc/debug-shared-mt/ -o .obj/debug-shared-mt/moc_topicchooserimpl.o .moc/debug-shared-mt/moc_topicchooserimpl.cpp *** buffer overflow detected ***: terminated make[2]: *** [Makefile:271: topicchooser.cpp] Aborted (core dumped) make[2]: *** Deleting file 'topicchooser.cpp' ``` See attached file for detailed output.
Francois added the
SL/critical
label 2 years ago
Poster
Collaborator

Zipped log file because of size limitation.

Zipped log file because of size limitation.
Owner

Hi Francois,
jsut trying to understand the problem a bit more.
Does the problem happens only in Fedora 38? In Fedora 37 you don't see this?
Is there any difference in the configuration for the two versions?
Does the problem happens if you try building with ninja instead of make?
How about if you use clang instead of gcc?

This seems to be a tricky one to debug, but obviously we need to find a solution for it.

Hi Francois, jsut trying to understand the problem a bit more. Does the problem happens only in Fedora 38? In Fedora 37 you don't see this? Is there any difference in the configuration for the two versions? Does the problem happens if you try building with ninja instead of make? How about if you use clang instead of gcc? This seems to be a tricky one to debug, but obviously we need to find a solution for it.
Poster
Collaborator

Hello Michele,

The problem only occurs on Fedora 38, no problem on Fedora 37.
I'm using the same build environment for both distributions. The only potential difference are the cflags/cxxflags: I'm using the distribution defaults build flags, which may differ accross distributions.

I don't manage to build tqt3 using ninja, it looks like script './configure' is hardcoded to use make/gmake.

Trying to build with clang, I'm getting error :

clang++ -o tqmake project.o property.o main.o makefile.o unixmake2.o unixmake.o msvc_nmake.o borland_bmake.o mingw_make.o msvc_dsp.o msvc_vcproj.o option.o winmakefile.o projectgenerator.o metrowerks_xml.o  pbuilder_pbx.o msvc_objectmodel.o meta.o qtmd5.o qstring.o qtextstream.o qiodevice.o qglobal.o qgdict.o qcstring.o qdatastream.o qgarray.o qbuffer.o qglist.o qptrcollection.o qfile.o qfile_unix.o qregexp.o qgvector.o qgcache.o qbitarray.o qdir.o quuid.o qfileinfo_unix.o qdir_unix.o qfileinfo.o qdatetime.o qstringlist.o qmap.o qconfig.o qunicodetables.o qsettings.o qlocale.o  -luuid
project.o: file not recognized: file format not recognized
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[1]: *** [Makefile:54: tqmake] Error 1
gmake[1]: Leaving directory '/tmp/BUILD.fc38.x86_64/trinity-tqt3-14.1.0/qmake'
qmake failed to build. Aborting.

It looks like GNU ld does not like clang compiled code.

Hello Michele, The problem only occurs on Fedora 38, no problem on Fedora 37. I'm using the same build environment for both distributions. The only potential difference are the cflags/cxxflags: I'm using the distribution defaults build flags, which may differ accross distributions. I don't manage to build tqt3 using ninja, it looks like script './configure' is hardcoded to use make/gmake. Trying to build with clang, I'm getting error : ``` clang++ -o tqmake project.o property.o main.o makefile.o unixmake2.o unixmake.o msvc_nmake.o borland_bmake.o mingw_make.o msvc_dsp.o msvc_vcproj.o option.o winmakefile.o projectgenerator.o metrowerks_xml.o pbuilder_pbx.o msvc_objectmodel.o meta.o qtmd5.o qstring.o qtextstream.o qiodevice.o qglobal.o qgdict.o qcstring.o qdatastream.o qgarray.o qbuffer.o qglist.o qptrcollection.o qfile.o qfile_unix.o qregexp.o qgvector.o qgcache.o qbitarray.o qdir.o quuid.o qfileinfo_unix.o qdir_unix.o qfileinfo.o qdatetime.o qstringlist.o qmap.o qconfig.o qunicodetables.o qsettings.o qlocale.o -luuid project.o: file not recognized: file format not recognized clang-16: error: linker command failed with exit code 1 (use -v to see invocation) gmake[1]: *** [Makefile:54: tqmake] Error 1 gmake[1]: Leaving directory '/tmp/BUILD.fc38.x86_64/trinity-tqt3-14.1.0/qmake' qmake failed to build. Aborting. ``` It looks like GNU ld does not like clang compiled code.
Owner

Hi Francois,
I guess it may be worth checking if there is any difference in cflags/cxxflags between v37 and v38, although it sounds a bit weird if the problem comes from there. I think the problem is more likely to come from different gcc versions, with the one in v38 probably doing some different things.
If you could upload the required docker file for fedora 38 on tde-packaging, I will try replicating the issue here during the coming week, following your instruction from here.

Hi Francois, I guess it may be worth checking if there is any difference in cflags/cxxflags between v37 and v38, although it sounds a bit weird if the problem comes from there. I think the problem is more likely to come from different gcc versions, with the one in v38 probably doing some different things. If you could upload the required docker file for fedora 38 on tde-packaging, I will try replicating the issue here during the coming week, following your instruction from [here](https://mirror.git.trinitydesktop.org/gitea/TDE/bibletime/issues/6#issuecomment-24667).
Owner

@Francois
Btw, since this may take a while to get fixed and since R14.1.0 has officially been released, would you mind uploading the packages for the distros for which RPM already exists so that users can update?

@Francois Btw, since this may take a while to get fixed and since R14.1.0 has officially been released, would you mind uploading the packages for the distros for which RPM already exists so that users can update?
Poster
Collaborator

Yes, I'm currently signing and preparing packages for other distributions :)

I've just commit/push the docker files for fedora38 in r14.1.x branch.

I've tried using 'lld' linker instead of 'ld'. I get strange build results:

gcc + ld: FTBFS
gcc + lld: OK
clang + ld: FTBFS
clang + lld: FTBFS

Yes, I'm currently signing and preparing packages for other distributions :) I've just commit/push the docker files for fedora38 in r14.1.x branch. I've tried using 'lld' linker instead of 'ld'. I get strange build results: gcc + ld: FTBFS gcc + lld: OK clang + ld: FTBFS clang + lld: FTBFS
Owner

I've just commit/push the docker files for fedora38 in r14.1.x branch.

Great, I will take a look during next week and let you know what I can find.

> I've just commit/push the docker files for fedora38 in r14.1.x branch. Great, I will take a look during next week and let you know what I can find.
Poster
Collaborator

Things are getting stranger ...
When insisting with 'make' command, it ends up building ...

After the FTBFS occurs, go to the failed directory, e.g. '/tmp/BUILD.fc38.x86_64/trinity-tqt3-14.1.0/qmake', then run 'make'.
After several attempts (about 5), it ends up compiling ...

Things are getting stranger ... When insisting with 'make' command, it ends up building ... After the FTBFS occurs, go to the failed directory, e.g. '/tmp/BUILD.fc38.x86_64/trinity-tqt3-14.1.0/qmake', then run 'make'. After several attempts (about 5), it ends up compiling ...
Owner

Hi @Francois,
I managed to build the f38 container and take a look.
The problem comes from the new _FORTIFY_SOURCE=3 introduced in recent gcc. As a temporary workaround, if you force _FORTIFY_SOURCE=2 (as I suspect it is the default in f37) tqt3 builds fine.
This is obviously a workaround for the time being, we need to track down what is causing the buffer overflow with _FORTIFY_SOURCE=3 since it may become the standard in other distros too and therefore likely to affect future builds.
For a quick test, try this patch. It is probably not the correct way to set CFLAGS in fedora, but it shows that tqt3 builds.

diff --git a/redhat/dependencies/tqt3/tqt3.spec b/redhat/dependencies/tqt3/tqt3.spec
index 4d79d2247..a1faff665 100644
--- a/redhat/dependencies/tqt3/tqt3.spec
+++ b/redhat/dependencies/tqt3/tqt3.spec
@@ -1270,7 +1270,7 @@ echo "sle_version = %{?sle_version}"
   -e "s|^QMAKE_INCDIR_TQT.*|QMAKE_INCDIR_TQT    = %{_includedir}/tqt3|" \
   -e "s|\$(QTDIR)|/usr|g" \
   -e "s|-lqt|-ltqt|g" \
-  -e "s|^QMAKE_CFLAGS   =.*|QMAKE_CFLAGS    = %{?optflags} -pipe -fvisibility=hidden -fvisibility-inlines-hidden|" \
+  -e "s|^QMAKE_CFLAGS   =.*|QMAKE_CFLAGS    = %{?optflags} -pipe -fvisibility=hidden -fvisibility-inlines-hidden -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=2|" \
   -e "s|^QMAKE_INCDIR   =.*|QMAKE_INCDIR    = %{_includedir}|" \
   -e "s|^QMAKE_LIBDIR   =.*|QMAKE_LIBDIR    = %{_libdir}|" \
   -e "s|^QMAKE_RPATH    = .*|QMAKE_RPATH    =|" \
Hi @Francois, I managed to build the f38 container and take a look. The problem comes from the new `_FORTIFY_SOURCE=3` introduced in recent gcc. As a temporary workaround, if you force `_FORTIFY_SOURCE=2` (as I suspect it is the default in f37) tqt3 builds fine. This is obviously a workaround for the time being, we need to track down what is causing the buffer overflow with `_FORTIFY_SOURCE=3` since it may become the standard in other distros too and therefore likely to affect future builds. For a quick test, try this patch. It is probably not the correct way to set CFLAGS in fedora, but it shows that tqt3 builds. ``` diff --git a/redhat/dependencies/tqt3/tqt3.spec b/redhat/dependencies/tqt3/tqt3.spec index 4d79d2247..a1faff665 100644 --- a/redhat/dependencies/tqt3/tqt3.spec +++ b/redhat/dependencies/tqt3/tqt3.spec @@ -1270,7 +1270,7 @@ echo "sle_version = %{?sle_version}" -e "s|^QMAKE_INCDIR_TQT.*|QMAKE_INCDIR_TQT = %{_includedir}/tqt3|" \ -e "s|\$(QTDIR)|/usr|g" \ -e "s|-lqt|-ltqt|g" \ - -e "s|^QMAKE_CFLAGS =.*|QMAKE_CFLAGS = %{?optflags} -pipe -fvisibility=hidden -fvisibility-inlines-hidden|" \ + -e "s|^QMAKE_CFLAGS =.*|QMAKE_CFLAGS = %{?optflags} -pipe -fvisibility=hidden -fvisibility-inlines-hidden -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=2|" \ -e "s|^QMAKE_INCDIR =.*|QMAKE_INCDIR = %{_includedir}|" \ -e "s|^QMAKE_LIBDIR =.*|QMAKE_LIBDIR = %{_libdir}|" \ -e "s|^QMAKE_RPATH = .*|QMAKE_RPATH =|" \ ```
Owner
For further info/reading, see here: https://developers.redhat.com/articles/2022/09/17/gccs-new-fortification-level
Owner

It may also be worth that enabling _FORTIFY_SOURCE=3 in f37 leads to the same problem, since the feature is available from gcc12, which is shipped in f37.

It may also be worth that enabling `_FORTIFY_SOURCE=3` in f37 leads to the same problem, since the feature is available from gcc12, which is shipped in f37.
Poster
Collaborator

Hello @MicheleC , thanks for your support.
You are correct, Fedora 37 uses FORTIFY_SOURCE=2 by default, whereas Fedora 38 uses FORTIFY_SOURCE=3.

Other packages, like tdelibs, are also impacted.

For now, I will set FORTIFY_SOURCE=2 for Fedora 38 and (attempt to) build all packages.

Hello @MicheleC , thanks for your support. You are correct, Fedora 37 uses FORTIFY_SOURCE=2 by default, whereas Fedora 38 uses FORTIFY_SOURCE=3. Other packages, like tdelibs, are also impacted. For now, I will set FORTIFY_SOURCE=2 for Fedora 38 and (attempt to) build all packages.
Owner

Other packages, like tdelibs, are also impacted.

Not surprised at all and I expect Debian and other distros to display the same behavior when gcc12 or higher is available and _FORTIFY_SOURCE is set to 3. It will probably be a long fixing up effort that span the whole TDE.

> Other packages, like tdelibs, are also impacted. Not surprised at all and I expect Debian and other distros to display the same behavior when gcc12 or higher is available and `_FORTIFY_SOURCE` is set to 3. It will probably be a long fixing up effort that span the whole TDE.
Owner

It may also be worth that enabling _FORTIFY_SOURCE=3 in f37 leads to the same problem, since the feature is available from gcc12, which is shipped in f37.

I tried forcing _FORTIFY_SOURCE=3 in Debian with gcc 12.2 and tqt3 failed with the same buffer overflow message. tdelibs though built fine.

> It may also be worth that enabling `_FORTIFY_SOURCE=3` in f37 leads to the same problem, since the feature is available from gcc12, which is shipped in f37. I tried forcing `_FORTIFY_SOURCE=3` in Debian with gcc 12.2 and tqt3 failed with the same buffer overflow message. tdelibs though built fine.
SlavekB commented 1 year ago
Owner

Automatic build for Noble (all architectures) fails. When manual triggering build in Noble build-root, it is completed without any problems. Build log attached.

Automatic build for Noble (all architectures) fails. When manual triggering build in Noble build-root, it is completed without any problems. Build log attached.
Poster
Collaborator

Hello, happy new year to all :)

After applying the tqt3 patch from #100, I've managed to rebuild all Fedora 39 packages using FORTIFYSOURCE=3.

So I believe this issue can be closed.

Hello, happy new year to all :) After applying the tqt3 patch from https://mirror.git.trinitydesktop.org/gitea/TDE/tqt3/pulls/100, I've managed to rebuild all Fedora 39 packages using FORTIFYSOURCE=3. So I believe this issue can be closed.
Owner

Great, thanks for the feedback @Francois and happy new year to you too!

Great, thanks for the feedback @Francois and happy new year to you too!
MicheleC closed this issue 1 year ago
SlavekB added this to the R14.1.2 release milestone 1 year ago
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: TDE/tqt3#70
Loading…
There is no content yet.