History log of /system/core/include/utils/RefBase.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
70a46d674a04e95da633a5914abd7a55a46e2b3e 12-May-2016 Hans Boehm <hboehm@google.com> Fix memory order and race bugs in Refbase.h & RefBase.cpp

Convert to use std::atomic directly.

Consistently use relaxed ordering for increments, release ordering
for decrements, and an added acquire fence when the count goes to
zero.

Fix what looks like another race in attemptIncStrong:
It seems entirely possible that the final adjustment for
INITIAL_STRONG_VALUE would see e.g. INITIAL_STRONG_VALUE + 1,
since we could be running in the middle of another initial
increment.

Attempt to somewhat document what this actually does, and
what's expected from the client. Hide the documentation in
the .cpp file for now.

Remove a confusing redundant test in decWeak. OBJECT_LIFETIME_STRONG
and OBJECT_LIFETIME_WEAK are the only options, in spite of some
of the original comments.

It's conceivable that either of these issues has resulted in
actual crashes, though I would guess the probability is small.
It's hard enough to reason about this code without the bugs.

Bug: 28705989
Change-Id: I4107a56c3fc0fdb7ee17fc8a8f0dd7fb128af9d8
(cherry picked from commit e263e6c6337a24d56dc803792206e54981ad53a5)
/system/core/include/utils/RefBase.h
aab3b34cd7b6243f30593fd2e4d6746866e797ef 07-Aug-2014 Elliott Hughes <enh@google.com> am 4c818dc8: am 56b28f6b: Merge "RefBase: make Renamer destructor virtual"

* commit '4c818dc800d97e2fdee0337a0e9736099d90cc47':
RefBase: make Renamer destructor virtual
00e56a248dd214555d9d0fda9d0f064e8d23e9cf 29-Apr-2014 Ukri Niemimuukko <ukri.niemimuukko@intel.com> RefBase: make Renamer destructor virtual

This patch makes the Renamer class destructor virtual and fixes
the incorrect constructor initialization list ordering.

These issues and related compiler warnings have been suppressed
by the build system which uses the gcc –isystem command
line option, unless a project explicitly adds the include the path
system/core/include to Android.mk and uses the templates.

Change-Id: Iff76a655eb8bd547adfe994c7315a005e98aed41
Signed-off-by: Ukri Niemimuukko <ukri.niemimuukko@intel.com>
Signed-off-by: Mingwei Shi <mingwei.shi@intel.com>
Signed-off-by: Yong Yao <yong.yao@intel.com>
/system/core/include/utils/RefBase.h
d83186c444809beaaf181b11c857bc2ab675428e 10-May-2014 John Reck <jreck@google.com> Add VirtualLightRefBase

Change-Id: I040db87d9e87ba0584e7e5bdd72f0c319a522fa1
/system/core/include/utils/RefBase.h
6cd548c7154c1633a0ed318c31dd22c50a5f5d02 19-Mar-2013 Mathias Agopian <mathias@google.com> Fix a crasher with RefBase debugging and vectors of wp<>

background:
we have some code to fix-up the IDs of references when
using RefBase's DEBUG_REFS when those refs are managed by
arrays wp<> or sp<> (this is because wp<> / sp<> don't have
a trivial ctor when DEBUG_REFS is enabled, and Vector
treats them as trivial for obvious performance reasons)

this is complicated by the fact that we don't want to have
to recompile everything when enabling DEBUG_REFs (i.e.: the
Vector code cannot know wheter it's enabled or not for its
template stuff).

problem:
there was a bug in the fix-up code for wp<> which was trying
to access the weakref_impl from the RefBase* however, this was
moronic since RefBase could have been destroyed if there wasn't
any more strong refs -- and this happned. Instead we need to get
the weakref_impl directly from the wp<>

Change-Id: Ie16e334204205fdbff142acb9faff8479a78450b
/system/core/include/utils/RefBase.h
a27c1e08396aa2969511dad1f661d10c2b835ac1 06-Dec-2012 Igor Murashkin <iam@google.com> utils: fix warnings for unused parameters

Change-Id: Ibfb755a30ba2923669060fe0aed019beecbe38a1
/system/core/include/utils/RefBase.h
9a0a76df1e961ef4621e81814d8bf891a09bef66 16-Mar-2012 Jeff Brown <jeffbrown@google.com> Add traits to common utils data structures.

Many of our basic data structures are trivially movable using
memcpy() even if they are not trivially constructable, destructable
or copyable. It's worth taking advantage of this *ahem* trait.

Adding trivial_move_trait to String16 reduces appt running
time on frameworks/base/core/res by 40%!

Change-Id: I630a1a027e2d0ded96856e4ca042ea82906289fe
/system/core/include/utils/RefBase.h
ad09965050f8226fda6f5238db060ce65abaa71c 11-Aug-2011 Mathias Agopian <mathias@google.com> fix a memory leak and memory corruption in RefBase

we would leak a weakref_impl if a RefBase was never incWeak()'ed.
there was also a dangling pointer that would cause memory corruption
and double-delete when a custom destroyer was used to delay the
execution of ~RefBase.

it turns out that the custom destroyer feature caused most of the
problems, so it's now gone. The only client was SurfaceFlinger
who now handles things on its own.

RefBase is essentially back its "gingerbread" state, but the
code was slightly cleaned-up.

Bug: 5151207, 5084978
Change-Id: Id6ef1d707f96d96366f75068f77b30e0ce2722a5
/system/core/include/utils/RefBase.h
7f57eac6a706b471f2dcadd15868797ea081306a 17-Jun-2011 Mathias Agopian <mathias@google.com> Revert "merge various SF fixes from gingerbread to honeycomb-mr2" (DO NOT MERGE)

Also revert all dependent changes:
This reverts commit 8e18668d14adf601cbe5973030c310ec23d88461.
This reverts commit 69b4587bfbb3e98f793959d9123340360fa233a2.
This reverts commit a9c9a4baf24700e8817d47d8ea8da1742caea0b5.
This reverts commit 2c0042b666a969091c931614f2fc0dce2f1cfac8.
This reverts commit f6c8206735e7e078461e5f2aef6e1a1446fdd075.
This reverts commit 24855c09173a6caaec7dcedd0c2d7ce15121d39b.

Change-Id: I33e699640f3f59e42fa03c99a9a1b7af0d27d4d8
/system/core/include/utils/RefBase.h
9c8fa9ed4111c69c82ace01c8a7ac3beeacdce78 16-Jun-2011 Mathias Agopian <mathias@google.com> revert surfaceflinger leak fix as it uncovered a crasher on xoom (DO NOT MERGE)

This reverts commit 52a43990880b27808bcf562afcc4209d34728e6e.

Change-Id: I1856a48f863b051395b8091ddfd1e01292fa1b1e
/system/core/include/utils/RefBase.h
267ba69c2e4ae39b9fe98d4be592c7b59e7e57a1 16-Jun-2011 Mathias Agopian <mathias@google.com> Revert "revert surfaceflinger leak fix as it uncovered a crasher on xoom"

This reverts commit af6edba59e250adbdfa5b3c3be134f70d8c38a16.

Change-Id: I7793d3ca8a4d20a2b188364f47854328ab5f586d
/system/core/include/utils/RefBase.h
dace0b45d00814dda275d81b82c1673dd88cf3e9 16-Jun-2011 Mathias Agopian <mathias@google.com> revert surfaceflinger leak fix as it uncovered a crasher on xoom

Bug: 4600244
Change-Id: Ia68ebf0f243a051ff6a21b3863e3e5d259bbf7ac
/system/core/include/utils/RefBase.h
0151ac8945216bb6c7ae23b6a7e449e5ede8a69c 14-Jun-2011 Mathias Agopian <mathias@google.com> may fix build on some version of gcc

Change-Id: Ia88787c0432ec84d51fe505fd6a2b6f98ebe8f33
/system/core/include/utils/RefBase.h
9b6259aa579291deb7334a968bd30878a5fec386 13-Jun-2011 Mathias Agopian <mathias@google.com> fix RefBase so it retains binary-compatibility with gingerbread (DO NOT MERGE)

Bug: 4595257
Change-Id: I1db83149107d7dab1f0b7e73c684e0ff82e17e62
/system/core/include/utils/RefBase.h
d781137601c05b623305592fbbe7b2d7d69087dd 20-May-2011 Mathias Agopian <mathias@google.com> RefBase subclasses can now decide how they want to be destroyed.

This adds a destroy() virtual on RefBase which
sublasses can implement. destroy() is called
in lieu of the destructor whenthe last strong
ref goes away.
/system/core/include/utils/RefBase.h
3e0f87541f7871ffde51c722d54550774fe1b7c3 25-Feb-2011 Mathias Agopian <mathias@google.com> Fix a wp<> bug where the owner ID would be wrong

this was introduced recently. we make sure to use
the correct owner id (the sp) instead of the wp.

Change-Id: I78fdc6ec0c2d3e687278b70442d74d1924b512a2
/system/core/include/utils/RefBase.h
b26ea8b30f11cf0ad11ac7983208514a1bfafb75 17-Feb-2011 Mathias Agopian <mathias@google.com> Fix some issues with RefBase debugging.

First slipt sp<> out of RefBase into StrongPointer.h so it can be reused
more easily and to make it clear that it doesn't require RefBase.

Note: the rest of the change only affects the system when DEBUG_REFS is enabled.

The main problem we fix here is that the owner id associated with each
reference could get out of date when a sp<> or wp<> was moved, for
instance when they're used in a Vector< >.

We fix this issue by calling into RefBase::moveReferences from
a template specialization for sp<TYPE> and wp<TYPE> of the
type helpers. RefBase::moveReferences() has then a chance to
update the owner ids.

There is a little bit of trickery to implement this generically in
RefBase, where we need to use a templatized functor that can turn
a sp<TYPE>* casted to a void* into a RefBase*.

Introduced a new debug option DEBUG_REFS_FATAL_SANITY_CHECKS
currently set to 0 by default as there seem to be an issue
with sp<ANativeWindow> which trips the sanity checks.

Change-Id: I4825b21c8ec47d4a0ef35d760760ae0c9cdfbd7f
/system/core/include/utils/RefBase.h
84a23fa4a9a2dca0f53fae2283b57fff988d1c74 17-Feb-2011 Mathias Agopian <mathias@google.com> Remove RefBase.h dependency on TextOutput.h

Change-Id: I72cd6b98ef82b4868fe1c8ec87862cf43fb4ee73
/system/core/include/utils/RefBase.h
ff49de731f3361afc77abe9b60bc7c8e6708f886 10-Feb-2011 Mathias Agopian <mathias@google.com> fix [3408713] Dialog window invisible sometimes

weak pointer comparison operators were implemented wrong,
they were using the internal "unsafe" pointer. We could end up
with two "equal" weak pointer pointing to different objects.

this caused KeyedVector keyed by weak pointer to work incorrectly, in
turn causing a window that just got added to a list to be immediately
removed.

Change-Id: Ib191010c39aafa9229109e4211f6c3b2b2f9696d
/system/core/include/utils/RefBase.h
7b1516795e6174fea6b12b3c4c3177e64e329ba6 25-Jun-2010 Mathias Agopian <mathias@google.com> Fix a bug in sp<> and wp<> which could cause memory corruptions

when assigning a smart pointer to another one, we need to make
sure to read all the data we need from the right-hand-side
reference (the assignee) before we decRef the assigned.

This bug would cause linked-list of smart-pointers to fail
miserably.

Change-Id: Ibb554c15fddf909f7737c632b7c80322e80ea93f
/system/core/include/utils/RefBase.h
019f8ed4274f788c90ca5f8a395fed706af5584c 04-May-2009 Mathias Agopian <mathias@google.com> update surfaceflinger, libui and libagl to the new gralloc api

- Currently the lock/unlock path is naive and is done for each drawing operation (glDrawElements and glDrawArrays). this should be improved eventually.
- factor all the lock/unlock code in SurfaceBuffer.
- fixed "showupdate" so it works even when we don't have preserving eglSwapBuffers().
- improved the situation with the dirty-region and fixed a problem that caused GL apps to not update.
- make use of LightRefBase() where needed, instead of duplicating its implementation
- add LightRefBase::getStrongCount()
- renamed EGLNativeWindowSurface.cpp to FramebufferNativeWindow.cpp

- disabled copybits test, since it clashes with the new gralloc api

- Camera/Video will be fixed later when we rework the overlay apis
/system/core/include/utils/RefBase.h
cbb1011c95e0c25c29e40e203a6a31bccd029da3 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/system/core/include/utils/RefBase.h
cf59fa8dc7ddca5a172860223b06afed5d4ec0e0 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/system/core/include/utils/RefBase.h
046e40caa03beba3b8b03527959ce97df9372b6a 10-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@125939
/system/core/include/utils/RefBase.h
d245d1d09731d6a19e8a25559d3907f54441ac3d 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution
/system/core/include/utils/RefBase.h