Open Bug 1270832 Opened 9 years ago Updated 1 year ago

turn on debug mode for clang libc++ headers

Categories

(Firefox Build System :: General, task)

task

Tracking

(firefox49 fixed)

ASSIGNED
mozilla49
Tracking Status
firefox49 --- fixed

People

(Reporter: froydnj, Assigned: jewilde)

Details

Attachments

(2 files)

STL usages have crept into the tree and will continue to creep in, especially as we move to a C++11 STL implementation everywhere. Let's at least enable a bit of checking for those data structures so we're not completely shooting ourselves in the foot.
This patch seems to work; the FIXME appears to be no longer applicable with newer GCC: https://treeherder.mozilla.org/#/jobs?repo=try&revision=7d9eb75e3d99
Attachment #8749640 - Flags: review?(mh+mozilla)
Comment on attachment 8749640 [details] [diff] [review] turn on debug mode for libstdc++ headers Review of attachment 8749640 [details] [diff] [review]: ----------------------------------------------------------------- ::: config/gcc-stl-wrapper.template.h @@ -45,5 @@ > > #if defined(DEBUG) && !defined(_GLIBCXX_DEBUG) > // Enable checked iterators and other goodies > -// > -// FIXME/bug 551254: gcc's debug STL implementation requires -frtti. Is this comment outdated?
Attachment #8749640 - Flags: review?(mh+mozilla)
(In reply to Mike Hommey [:glandium] from comment #2) > Comment on attachment 8749640 [details] [diff] [review] > turn on debug mode for libstdc++ headers > > Review of attachment 8749640 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: config/gcc-stl-wrapper.template.h > @@ -45,5 @@ > > > > #if defined(DEBUG) && !defined(_GLIBCXX_DEBUG) > > // Enable checked iterators and other goodies > > -// > > -// FIXME/bug 551254: gcc's debug STL implementation requires -frtti. > > Is this comment outdated? This comment appears to stem from bug 551254 comment 30, but the libstdc++ debug mode documentation makes no mention of the -frtti constraint: https://gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode_using.html#debug_mode.using.mode The only instances of |typeid| I can find in the debug headers are all guarded by preprocessor checks that RTTI is enabled. Spelunking in libstdc++ leads me to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160 , which would have been fixed somewhere in the GCC 4.5 timeframe. So yes, I think this comment is outdated. OK to commit, then?
Flags: needinfo?(mh+mozilla)
Attachment #8749640 - Flags: review+
Flags: needinfo?(mh+mozilla)
(In reply to Pulsebot from comment #6) > https://hg.mozilla.org/integration/mozilla-inbound/rev/ccff1c4580ab This revision landed with a change to ignore debug headers for static analysis. We're not running the static analysis build, so I figure that not having the debug-ness turned on here is not a bad thing.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Product: Core → Firefox Build System
The fuzzing team was interested in this; they may also be interested in comment 9, and the commit message for the backout.
Type: defect → task

The bug assignee didn't login in Bugzilla in the last 7 months, so the assignee is being reset.

Assignee: froydnj+bz → nobody
Severity: normal → S3

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.

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?

Flags: needinfo?(mh+mozilla)

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.

Flags: needinfo?(mh+mozilla)

Is this something we could enable per header file (directory, translation unit, ...) in order to enforce it step by step?

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?

Flags: needinfo?(jewilde)

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

  1. enabling the flag and surfacing the errors as warnings
  2. fixing everything found in tree and restoring the default functionality of calling std::abort on error
Assignee: nobody → jewilde
Status: REOPENED → ASSIGNED
Flags: needinfo?(jewilde)
Summary: turn on debug mode for libstdc++ headers → turn on debug mode for clang libc++ headers

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)

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: