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

RESOLVED FIXED in mozilla16

Status

()

Core
mozglue
RESOLVED FIXED
6 years ago
5 years ago

People

(Reporter: glandium, Assigned: glandium)

Tracking

Trunk
mozilla16
All
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

Comment hidden (empty)
(Assignee)

Comment 1

5 years ago
Created attachment 629776 [details] [diff] [review]
Call destructors in reverse order of initializers in the linker
Attachment #629776 - Flags: review?(nfroyd)
(Assignee)

Updated

5 years ago
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-
(Assignee)

Comment 3

5 years ago
Created attachment 630102 [details] [diff] [review]
Call destructors in reverse order of initializers in the linker

I also slipped a fix to the operator++ return type.
Attachment #630102 - Flags: review?(nfroyd)
(Assignee)

Updated

5 years ago
Attachment #629776 - Attachment is obsolete: true
Attachment #630102 - Flags: review?(nfroyd) → review+
(Assignee)

Comment 4

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/d03872d8e1b4
Target Milestone: --- → mozilla16

Comment 5

5 years ago
https://hg.mozilla.org/mozilla-central/rev/d03872d8e1b4
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.