Closed Bug 735278 Opened 9 years ago Closed 9 years ago

Linker doesn't call fini_array function in reverse order of those of init_array

Categories

(Core :: mozglue, defect)

All
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla16

People

(Reporter: glandium, Assigned: glandium)

Details

Attachments

(1 file, 1 obsolete file)

No description provided.
Assignee: nobody → mh+mozilla
Comment on attachment 629776 [details] [diff] [review]
Call destructors in reverse order of initializers in the linker

Review of attachment 629776 [details] [diff] [review]:
-----------------------------------------------------------------

::: mozglue/linker/Utils.h
@@ +536,5 @@
> +   * Returns a reverse iterator pointing past the beginning of the Array
> +   */
> +  reverse_iterator rend() const {
> +    if (length)
> +      return reverse_iterator(UnsizedArray<T>::operator[](-1));

I don't like this because it screws with bounds checking (which I realize is unimplemented, and we don't run static analyses for it) and also because I'm fairly certain that the ultimate effect of this produces undefined behavior according to the standard.  (Pointers just past the end of an object are OK; pointers before the beginning of an object are not.)  Rewrite to avoid this, please.
Attachment #629776 - Flags: review?(nfroyd) → review-
I also slipped a fix to the operator++ return type.
Attachment #630102 - Flags: review?(nfroyd)
Attachment #629776 - Attachment is obsolete: true
Attachment #630102 - Flags: review?(nfroyd) → review+
https://hg.mozilla.org/mozilla-central/rev/d03872d8e1b4
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.