turn on debug mode for libstdc++ headers
Categories
(Firefox Build System :: General, task)
Tracking
(firefox134 fixed)
Tracking | Status | |
---|---|---|
firefox134 | --- | fixed |
People
(Reporter: froydnj, Assigned: sergesanspaille)
References
(Depends on 1 open bug)
Details
Attachments
(3 files)
![]() |
Reporter | |
Comment 1•9 years ago
|
||
Comment 2•9 years ago
|
||
![]() |
Reporter | |
Comment 3•9 years ago
|
||
Updated•9 years ago
|
Updated•9 years ago
|
![]() |
Reporter | |
Comment 7•9 years ago
|
||
Comment 8•9 years ago
|
||
bugherder |
Comment 9•9 years ago
|
||
Updated•7 years ago
|
![]() |
Reporter | |
Comment 10•7 years ago
|
||
Updated•6 years ago
|
Comment 11•3 years ago
|
||
The bug assignee didn't login in Bugzilla in the last 7 months, so the assignee is being reset.
Updated•2 years ago
|
Comment 12•2 years ago
|
||
This was talked about recently in the Google-organized Memory Saftey Summit. They enabled these on Chromium and saw over 800 unique issues in 3 months so it definitely seems worth running down.
Comment 13•2 years ago
|
||
For easier reading, here is the backout reason from comment 9:
It turns out that, since we're including <new> before setting
_GLIBCXX_DEBUG, the debug parts of c++config.h are not activated, and
that has an impact of how much of the debug features of the STL are
activated.
In contrast, the upcoming changes to the STL wrappers are avoiding the
include of <new> before _GLIBCXX_DEBUG is set, which in turn breaks the
build because, as we link things that use STL wrappers with things that
don't, they end up with a different state of STL debugging, and have
mismatching symbols.
Mike, do you know if this is still an issue? Are there any other blockers for pursuing this?
Comment 14•2 years ago
|
||
I think it still is, short of building some things twice (e.g. some parts of the updater). Best way to tell for sure would be to do a try push.
Comment 15•2 years ago
|
||
Is this something we could enable per header file (directory, translation unit, ...) in order to enforce it step by step?
Comment 16•2 years ago
|
||
June, you said you tried turning this from error to warning recently and came up with a list of issues. Can you share that list?
Comment 17•2 years ago
|
||
As an update we're somewhat shifting this bug to be solely about clang's libc++ debug mode checks since we primarily build with clang now and gcc's libstdc++ counterpart already has Bug 556708 filed.
I'm having some trouble reproducing that list both locally and in try, but I'm attaching the patch I wrote to generate it here. It attempts to set LIBCXX_ENABLE_DEBUG_MODE
before any part of Firefox is compiled and forces the copy of clang that we build in automation to be built with LIBCXX_ENABLE_DEBUG_MODE
set and a custom version of _LIBCPP_VERBOSE_ABORT
to log the error, but not abort from the build.
To be able to utilize the stl debug mode we'll need to build llvm/clang with LIBCXX_ENABLE_DEBUG_MODE
set to true and then also use that build of clang to build debug Firefox with LIBCXX_ENABLE_DEBUG_MODE
set to true. I'm not sure if we would be able to use the same copy of clang to make other builds, however. As far as I can tell the ABI changes persist even if we don't set the debug mode flag when building Firefox.
As for whether or not we can do this by header file/translation unit/component/etc we'll have to enforce it all at once due to how the build flag works and we'll also need to make sure that any third party libraries we're building also have the flag enabled. We could however do it in two stages of
- enabling the flag and surfacing the errors as warnings
- fixing everything found in tree and restoring the default functionality of calling
std::abort
on error
Comment 18•2 years ago
|
||
Comment 19•2 years ago
|
||
since we primarily build with clang now
That's not actually related to whether or not we're using libc++, which we're actually not, on most platforms. We're only using libc++ on mac, and we're using the system one, at that.
(Also clang 17 removed LIBCXX_ENABLE_DEBUG_MODE, it now has different knobs)
Comment 20•1 year ago
|
||
Changing title back to libstdc++, since it's the relevant STL for our builds
This current version of the patch builds but fails to link with the following error, but I'm unsure what the cause is. The libstdc++.so
being linked in from the sysroot in the .mozbuild
directory is exporting the symbol which the linker ends up suggesting
[task 2023-10-17T03:20:53.903Z] 03:20:53 ERROR - ld.lld: error: undefined hidden symbol: __gnu_debug::_Error_formatter::_M_message(__gnu_debug::_Debug_msg_id) const
[task 2023-10-17T03:20:53.903Z] 03:20:53 INFO - >>> referenced by stl_algobase.h:452 (/builds/worker/fetches/sysroot-i686-linux-gnu/usr/lib/gcc/i586-linux-gnu/8/../../../../include/c++/8/bits/stl_algobase.h:452)
[task 2023-10-17T03:20:53.904Z] 03:20:53 INFO - >>> /builds/worker/workspace/obj-build/toolkit/library/gtest/../../../mfbt/tests/gtest/TestAlgorithm.o:(void std::vector<long long, std::allocator<long long>>::_M_realloc_insert<long long>(__gnu_cxx::__normal_iterator<long long*, std::vector<long long, std::allocator<long long>>>, long long&&))
[task 2023-10-17T03:20:53.904Z] 03:20:53 INFO - >>> referenced by stl_algobase.h:452 (/builds/worker/fetches/sysroot-i686-linux-gnu/usr/lib/gcc/i586-linux-gnu/8/../../../../include/c++/8/bits/stl_algobase.h:452)
[task 2023-10-17T03:20:53.904Z] 03:20:53 INFO - >>> /builds/worker/workspace/obj-build/toolkit/library/gtest/../../../mfbt/tests/gtest/TestAlgorithm.o:(void std::vector<long long, std::allocator<long long>>::_M_range_initialize<long long const*>(long long const*, long long const*, std::forward_iterator_tag))
[task 2023-10-17T03:20:53.904Z] 03:20:53 INFO - >>> referenced by stl_algobase.h:1047 (/builds/worker/fetches/sysroot-i686-linux-gnu/usr/lib/gcc/i586-linux-gnu/8/../../../../include/c++/8/bits/stl_algobase.h:1047)
[task 2023-10-17T03:20:53.905Z] 03:20:53 INFO - >>> /builds/worker/workspace/obj-build/toolkit/library/gtest/../../../mfbt/tests/gtest/TestAlgorithm.o:(testing::AssertionResult testing::internal::CmpHelperEQ<std::vector<long long, std::allocator<long long>>, std::vector<long long, std::allocator<long long>>>(char const*, char const*, std::vector<long long, std::allocator<long long>> const&, std::vector<long long, std::allocator<long long>> const&))
[task 2023-10-17T03:20:53.905Z] 03:20:53 INFO - >>> referenced 14409 more times
[task 2023-10-17T03:20:53.905Z] 03:20:53 INFO - >>> did you mean: __gnu_debug::_Error_formatter::_M_message(__gnu_debug::_Debug_msg_id) const@GLIBCXX_3.4
[task 2023-10-17T03:20:53.905Z] 03:20:53 INFO - >>> defined in: /builds/worker/fetches/sysroot-i686-linux-gnu/usr/lib/gcc/i586-linux-gnu/8/libstdc++.so
Updated•1 year ago
|
Updated•1 year ago
|
Comment 21•1 year ago
|
||
We will need a new owner if we want to continue pursuing this.
Assignee | ||
Comment 22•5 months ago
|
||
For both libc++ and libstdc++, they have different macro to activate
those, and different feature check.
This is a debug-only feature, given the overhead.
Updated•5 months ago
|
Updated•5 months ago
|
Updated•4 months ago
|
Updated•3 months ago
|
Comment 23•3 months ago
|
||
Comment 24•3 months ago
|
||
bugherder |
Updated•3 months ago
|
Updated•3 months ago
|
Description
•