Closed Bug 1758005 Opened 2 years ago Closed 2 years ago

Firefox fails to link with GCC12 - undefined reference to `std::__glibcxx_assert_fail

Categories

(Firefox Build System :: General, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: stransky, Unassigned)

References

(Blocks 1 open bug)

Details

Firefox fails to link with GCC 12:

18:04.86 /usr/include/c++/12/bits/stl_vector.h:1229: undefined reference to `std::__glibcxx_assert_fail(char const*, int, char const*, char const*)'
18:04.91 /usr/bin/ld: /home/komat/rpmbuild/BUILD/firefox-97.0.1/objdir/instrumented/toolkit/library/build/../../../security/sandbox/linux/launch/Unified_cpp_linux_launch0.o: in function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned long)':
18:04.91 /usr/include/c++/12/bits/basic_string.h:1221: undefined reference to `std::__glibcxx_assert_fail(char const*, int, char const*, char const*)'
18:04.91 /usr/bin/ld: /home/komat/rpmbuild/BUILD/firefox-97.0.1/objdir/instrumented/toolkit/library/build/../../../security/sandbox/linux/launch/Unified_cpp_linux_launch0.o: in function `std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >::back()':
18:04.91 /usr/include/c++/12/bits/stl_vector.h:1229: undefined reference to `std::__glibcxx_assert_fail(char const*, int, char const*, char const*)'
18:04.91 /usr/bin/ld: /home/komat/rpmbuild/BUILD/firefox-97.0.1/objdir/instrumented/toolkit/library/build/../../../security/sandbox/linux/launch/Unified_cpp_linux_launch0.o: in function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned long)':
18:04.91 /usr/include/c++/12/bits/basic_string.h:1221: undefined reference to `std::__glibcxx_assert_fail(char const*, int, char const*, char const*)'
18:04.94 /usr/bin/ld: /home/komat/rpmbuild/BUILD/firefox-97.0.1/objdir/instrumented/toolkit/library/build/../../../security/sandbox/linux/reporter/Unified_cpp_linux_reporter0.o: in function `std::__atomic_base<mozilla::OffTheBooksMutex*>::compare_exchange_strong(mozilla::OffTheBooksMutex*&, mozilla::OffTheBooksMutex*, std::memory_order, std::memory_order)':
18:04.94 /usr/include/c++/12/bits/atomic_base.h:876: undefined reference to `std::__glibcxx_assert_fail(char const*, int, char const*, char const*)'
18:04.94 /usr/bin/ld: /home/komat/rpmbuild/BUILD/firefox-97.0.1/objdir/instrumented/toolkit/library/build/../../../security/sandbox/linux/reporter/Unified_cpp_linux_reporter0.o:/usr/include/c++/12/bits/atomic_base.h:817: more undefined references to `std::__glibcxx_assert_fail(char const*, int, char const*, char const*)' follow

Mike, any idea here? It's Fedora 36 system with GCC12.
Thanks.

Flags: needinfo?(mh+mozilla)

This affects security/sandbox/linux only and __glibcxx_assert_fail is exported from stdlib as:
std::__glibcxx_assert_fail(char const*, int, char const*, char const*)@@GLIBCXX_3.4.30

Clang throws a different error:

15:22.17 ld.lld: error: undefined hidden symbol: std::__glibcxx_assert_fail(char const*, int, char const*, char const*)
15:22.17 >>> referenced by stl_vector.h:1229 (/usr/include/c++/12/bits/stl_vector.h:1229)
15:22.17 >>> /home/komat/rpmbuild/BUILD/firefox-98.0/objdir/toolkit/library/build/../../../security/sandbox/linux/broker/Unified_cpp_linux_broker0.o:(mozilla::SandboxBrokerPolicyFactory::InitContentPolicy())
15:22.17 >>> referenced by basic_string.h:1221 (/usr/include/c++/12/bits/basic_string.h:1221)
15:22.17 >>> /home/komat/rpmbuild/BUILD/firefox-98.0/objdir/toolkit/library/build/../../../security/sandbox/linux/launch/Unified_cpp_linux_launch0.o:(std::__cxx11::to_string(int))
15:22.17 >>> referenced by stl_vector.h:1229 (/usr/include/c++/12/bits/stl_vector.h:1229)
15:22.17 >>> /home/komat/rpmbuild/BUILD/firefox-98.0/objdir/toolkit/library/build/../../../security/sandbox/linux/launch/Unified_cpp_linux_launch0.o:(std::pair<int, int>& std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >::emplace_back<std::pair<int, int> >(std::pair<int, int>&&) (.isra.0))
15:22.17 >>> referenced 2221 more times
15:22.17 >>> did you mean: std::__glibcxx_assert_fail(char const*, int, char const*, char const*)@GLIBCXX_3.4.30

Priority: -- → P3

Can't reproduce with gcc-12 (Debian 12-20220302-1) 12.0.1 20220302 (experimental) [master r12-7448-g58394373a70]

Flags: needinfo?(mh+mozilla)

Actually, I can reproduce once I manually set -D_GLIBCXX_ASSERTIONS

So, lld is giving the most insightful error message (undefined hidden symbol), but instead of focusing on object files that contain a reference to the hidden symbol, it shows object files that contain a reference to the non-hidden symbol, which is not super helpful. Scanning all object files, one can find affected files, then preprocess at least one of them, and figure out c++config.h (where __glibcxx_assert_fail is defined) is sometimes includes via a header that is not wrapped and thus doesn't unhide system symbols.

I'd argue there's a bug in GCC, because define a function in c++config.h seems dubious.

That said, I'd expect this to have fixed it: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=4cb935cb69f12088975fa7f6907c6ace0580e2dd

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.