Closed Bug 573786 Opened 14 years ago Closed 14 years ago

Script to detect static initializers

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: taras.mozilla, Assigned: ehren.m)

References

Details

Attachments

(2 files, 3 obsolete files)

Need a *hydra script to detect these. I think it's a matter of looking for generated functions that are destined for .ctors section.
Attached patch script (obsolete) (deleted) — Splinter Review
It's a bit messy to hardcode the name __static_initialization_and_destruction but this is what's done by gcc.
Attachment #453309 - Flags: review?(tglek)
Attached file results (deleted) —
note that the calls to __cxa_atexit are to ensure that the destructor for a statically initialized object is called on library unload/exit.
(In reply to comment #2)
> Created an attachment (id=453310) [details]
> results
> 
> note that the calls to __cxa_atexit are to ensure that the destructor for a
> statically initialized object is called on library unload/exit.

Yeah, those are often harmful too. https://bugzilla.mozilla.org/show_bug.cgi?id=569629#c11

Very nice. You even found a few nsCOMPtr globals. Excellent work!
Comment on attachment 453309 [details] [diff] [review]
script

>+          warning(pretty_var(arg) + " defined by call to constructor " + pretty_func(decl) +

>+          warning(pretty_func(decl) + " called during static initialization", location_of(decl));

Nice detailed error messages. This is even better than I expected.
Attachment #453309 - Flags: review?(tglek) → review+
Attached patch patch v2 (obsolete) (deleted) — Splinter Review
changing to use cfg_isn_iterator, carrying over r+.
Attachment #453309 - Attachment is obsolete: true
Attachment #454657 - Flags: review+
Keywords: checkin-needed
Attached patch patch v3 (obsolete) (deleted) — Splinter Review
missed a testcase, carrying over r+
Attachment #454657 - Attachment is obsolete: true
Attachment #455524 - Flags: review+
Attached patch patch (deleted) — Splinter Review
added commit message to patch
Attachment #455524 - Attachment is obsolete: true
Attachment #466456 - Flags: review+
Comment on attachment 466456 [details] [diff] [review]
patch

http://hg.mozilla.org/mozilla-central/rev/b240b82abfaf
Status: NEW → RESOLVED
Closed: 14 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Product: Core → Firefox Build System
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: