Closed Bug 573786 Opened 10 years ago Closed 10 years ago

Script to detect static initializers

Categories

(Firefox Build System :: Source Code Analysis, defect)

x86
Linux
defect
Not set

Tracking

(Not tracked)

RESOLVED FIXED

People

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

References

(Blocks 1 open bug)

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) — 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
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) — 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) — Splinter Review
missed a testcase, carrying over r+
Attachment #454657 - Attachment is obsolete: true
Attachment #455524 - Flags: review+
Attached patch patchSplinter Review
added commit message to patch
Attachment #455524 - Attachment is obsolete: true
Attachment #466456 - Flags: review+
Status: NEW → RESOLVED
Closed: 10 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.