New issue
Advanced search Search tips

Issue 884811 link

Starred by 1 user

Issue metadata

Status: Untriaged
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Should we use -fno-c++-static-destructors?

Project Member Reported by thakis@chromium.org, Sep 17

Issue description

clang grew a flag that disables calling C++ destructors at program turndown time: https://reviews.llvm.org/rL340306

Should we use it?

It's somewhat similar to the very old desire to just _exit(0) at exit time.

Since we shouldn't lose data on crashes either, turning this on should be safe-ish (modulo data loss bugs on crashes).


cc'ing some folks from "[chromium-dev] Should we stop supporting clean shutdown in Chrome? [was: How does Chrome shutdown work on Android?]"
 
I'm hesitant on this.

We definitely don't want destructors running at program exit.  But a flag to make them silently not run seems maybe worse than a flag that, I dunno, breaks the compile if you have static destructors, or something.  That way if people try to add one of these, it will loudly not do what they want.
The break compile flag for this is -Wexit-time-destructors. Tracked in issue 801563. I agree with Peter that it's preferable to remove static destructors then to silence them out.
-Wexit-time-destructors is actually 101600 from 7 years ago. I agree it's a nicer approach in theory, but in practice it's not getting done.

So we could hope that things look better in the next 7 years, or we could add that flag and see what happens :-)
For instance, r529233 caused  issue 805443  merely by terminating-process at the very end of main() (i.e. only skipping static destructors) because it prevented logging destructors from completing flushes (which broke chrome --version on CrOS)... (I never got back around to another try on that one but I suspect -fno-c++-static-destructors would regress that)
If there are a handful of mission-critical dtors, we could annotation them with  [[clang::always_destroy]], turn on the flag, and then work on removing those over time.

Sign in to add a comment