Last Comment Bug 735278 - Linker doesn't call fini_array function in reverse order of those of init_array
: Linker doesn't call fini_array function in reverse order of those of init_array
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: mozglue (show other bugs)
: Trunk
: All Linux
: -- normal (vote)
: mozilla16
Assigned To: Mike Hommey [:glandium]
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-13 09:32 PDT by Mike Hommey [:glandium]
Modified: 2012-06-07 08:00 PDT (History)
1 user (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Call destructors in reverse order of initializers in the linker (2.69 KB, patch)
2012-06-04 07:50 PDT, Mike Hommey [:glandium]
nfroyd: review-
Details | Diff | Splinter Review
Call destructors in reverse order of initializers in the linker (3.13 KB, patch)
2012-06-05 01:52 PDT, Mike Hommey [:glandium]
nfroyd: review+
Details | Diff | Splinter Review

Description Mike Hommey [:glandium] 2012-03-13 09:32:14 PDT

    
Comment 1 Mike Hommey [:glandium] 2012-06-04 07:50:13 PDT
Created attachment 629776 [details] [diff] [review]
Call destructors in reverse order of initializers in the linker
Comment 2 Nathan Froyd [:froydnj] 2012-06-04 17:28:18 PDT
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.
Comment 3 Mike Hommey [:glandium] 2012-06-05 01:52:52 PDT
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.
Comment 5 Ed Morley [:emorley] 2012-06-07 08:00:45 PDT
https://hg.mozilla.org/mozilla-central/rev/d03872d8e1b4

Note You need to log in before you can comment on or make changes to this bug.