Commit graph

99 commits

Author SHA1 Message Date
tedbo
9d8be5485c get_malloc_leak_info: Fix assumption that totalMemory out parameter was initialized to zero.
The get_malloc_leak_info() currently asssumes that the totalMemory out parameter
was pre-initialized to zero before the routine is called. If it is not then the
accumulated totalMemory value will be incorrect. It is likely that many callers
will simply allocate totalMemory on the stack with no initialization and assume
that get_malloc_leak_info will set the proper value.

As an example, the caller in frameworks/base/core/jni/android_os_Debug.cpp
calls get_malloc_leak_info() with the address uninitiazed stack variable
for totalMemory. It is probably best to fix this in get_malloc_leak_info.

Change-Id: I84c927c3781419585794726115b7d34d8fdd24ae
2010-10-05 13:23:28 -07:00
Andy McFadden
b1c9cc2f2d Add memory barriers to pthread_once.
The implementation was using a double-checked locking approach that
could break on SMP.

In addition to the barriers I also switched to a volatile pointer.  I
don't think this will matter unless gcc can conclude that _normal_lock
can't affect *once_control, but I figured it was better to be safe.
(It seems to have no impact whatsoever on the generated code.)

Bug 3022795.

Change-Id: Ib91da25d57ff5bee4288526e39d457153ef6aacd
2010-09-23 12:30:12 -07:00
Andy McFadden
e2ac89869f Add a memory barrier to cond var signaling.
This adds an explicit memory barrier to condition variable signaling.
It's a little murky as to whether it's strictly required, but it seems
like a wise thing to do.

Change-Id: Id0faa542d61e4b8ffa775e4adf68e4d7471f4fb7
2010-09-02 13:34:53 -07:00
Christopher Tate
caaf7ecd1c am 1ff91085: am 52e7d3d9: Bulletproof leak dump against null hash entries
Merge commit '1ff910858c8ae5863761101c673a196a6a16bca3'

* commit '1ff910858c8ae5863761101c673a196a6a16bca3':
  Bulletproof leak dump against null hash entries
2010-08-09 19:57:25 -07:00
Christopher Tate
1ff910858c am 52e7d3d9: Bulletproof leak dump against null hash entries
Merge commit '52e7d3d91ab6a5bab77c5dfb1ed47381fd52f9ba' into gingerbread-plus-aosp

* commit '52e7d3d91ab6a5bab77c5dfb1ed47381fd52f9ba':
  Bulletproof leak dump against null hash entries
2010-08-09 19:53:32 -07:00
Christopher Tate
52e7d3d91a Bulletproof leak dump against null hash entries
Previously, the malloc leak checking code would crash in qsort()
if null entries existed in its bookkeeping table.  This change
makes the comparison function detect null entries and sort them
to the end safely.

Change-Id: I88244a7df1e289dd9d7992ce29606d505bd63079
2010-08-09 13:43:46 -07:00
Jean-Baptiste Queru
6b9d2d6839 am 6d4d8cb7: resolved conflicts for merge of 4f086aeb to gingerbread-plus-aosp
Merge commit '6d4d8cb79c5578d33ab17806d67b1e53a730fbc3'

* commit '6d4d8cb79c5578d33ab17806d67b1e53a730fbc3':
  Implemented pthread_atfork()
2010-07-23 15:04:24 -07:00
Jean-Baptiste Queru
6d4d8cb79c resolved conflicts for merge of 4f086aeb to gingerbread-plus-aosp
Change-Id: Ice2a6d41a7e9d04eca02e15ed189d648d61b5801
2010-07-23 13:53:19 -07:00
Matt Fischer
4f086aeb4a Implemented pthread_atfork()
Change-Id: Ie6c0bf593315d3507b3c4a6c8903a74a1fa053db
2010-07-23 13:10:16 -07:00
The Android Open Source Project
fb6907d39c am 0e78f786: merge from open-source master
Merge commit '0e78f786777a04af498b43564a8d6ed8e15e8940'

* commit '0e78f786777a04af498b43564a8d6ed8e15e8940':
  Change-Id: I68cc462aeb2460345a53bdb9941ce4bfc10456fb
2010-07-09 10:54:06 -07:00
The Android Open Source Project
0e78f78677 merge from open-source master
Change-Id: Id84ff747889d6f2c15c0510263e32fdfdd18dbed
2010-07-09 10:48:45 -07:00
Jean-Baptiste Queru
fc6d95b10e Merge "Change-Id: I68cc462aeb2460345a53bdb9941ce4bfc10456fb bionic: fix clearenv() compiler warning and related comment typos" 2010-07-08 15:38:13 -07:00
David 'Digit' Turner
cf38531741 resolved conflicts for merge of 2576abf0 to master
Change-Id: Ibd3ed11f3cc27ff12c0464b0f56d7057be6a7b85
2010-07-02 15:22:19 -07:00
David 'Digit' Turner
519763265e libc: Fix sem_post() implementation to wake up all waiting threads.
This also allows us to optimize the case where we increment an
uncontended semaphore (no need to call futex_wake() then).

Change-Id: Iad48efe8551dc66dc89d3e3f18c001e5a6c1939f
2010-07-02 15:09:57 -07:00
David 'Digit' Turner
3b43f87d29 Allow dlclose() to properly call static C++ destructors.
With this patch _and_ an upcoming build/ patch, the destruction
of static C++ objects contained in shared libraries will happen
properly when dlclose() is called.

Note that this change introduces crtbegin_so.S and crtend_so.S which
are currently ignored by the build system.

+ move definition of __dso_handle to the right place
(before that, all shared libraries used the __dso_handle
global variable from the C library).

Note that we keep a 'weak' __dso_handle in aeabi.c to avoid
breaking the build until the next patch to build/core/combo/
appears. We will be able to remove that later.

+ move bionic/aeabi.c to arch-arm/bionic/ (its proper location)

NOTE: The NDK will need to be modified to enable this feature in
         the shared libraries that are generated through it.

Change-Id: I99cd801375bbaef0581175893d1aa0943211b9bc
2010-07-01 23:09:28 -07:00
David 'Digit' Turner
4e6043a355 am 7d1d98b9: am a02b93bd: libc: add sanity checks to pthread_mutex_destroy()
Merge commit '7d1d98b97e947de22aff4c0b67eec7ae68c822ee'

* commit '7d1d98b97e947de22aff4c0b67eec7ae68c822ee':
  libc: add sanity checks to pthread_mutex_destroy()
2010-06-29 12:55:34 -07:00
David 'Digit' Turner
a02b93bd75 libc: add sanity checks to pthread_mutex_destroy()
Change-Id: Iddb2204fa792fa9aca5f19838926dddbb09b74a2
2010-06-28 14:20:22 -07:00
Wink Saville
ccc3d1eea1 Use a recursive lock for pthread_once.
bug: 2292366
Change-Id: I9fc8b790dcfcb30ca94a0beb340d43fe5cd6c22e
2010-06-28 11:41:16 -07:00
Chris Peterson
2bf607d599 Change-Id: I68cc462aeb2460345a53bdb9941ce4bfc10456fb
bionic: fix clearenv() compiler warning and related comment typos
2010-06-27 20:53:04 -07:00
David 'Digit' Turner
50ace4fec5 Remove compiler warnings when building Bionic.
Also add missing declarations to misc. functions.
Fix clearerr() implementation (previous was broken).
Handle feature test macros like _POSIX_C_SOURCE properly.

Change-Id: Icdc973a6b9d550a166fc2545f727ea837fe800c4
2010-06-22 17:51:41 -07:00
David 'Digit' Turner
6a9b888d7c Allow static C++ destructors to be properly called on dlclose().
With this patch, _and_ an upcoming build/ patch, the destruction
of static C++ objects contained in shared libraries will happen
properly when dlclose() is called.

Note that this change introduces crtbegin_so.S and crtend_so.S which
are currently ignored by the build system.

+ move definition of __dso_handle to the right place
  (before that, all shared libraries used the __dso_handle
   global variable from the C library).

  Note that we keep a 'weak' __dso_handle in aeabi.c to avoid
  breaking the build until the next patch to build/core/combo/
  appears. We will be able to remove that later.

+ move bionic/aeabi.c to arch-arm/bionic/ (its proper location)

Change-Id: Ie771aa204e3acbdf02fd30ebd4150373a1398f39
NOTE: The NDK will need to be modified to enable this feature in
      the shared libraries that are generated through it.
2010-06-18 16:07:10 -07:00
David 'Digit' Turner
6c8a2f2a5b libc: remove cutils dependencies
We simply copy the stuff we need from cutils headers.

A future patch will change cutils to include the private <bionic_atomic_inline.h>

Change-Id: Ib6fd9a03bc9e337ce867bd606dc94c2b4438480a
2010-06-11 13:49:09 -07:00
David 'Digit' Turner
6304d8b218 Use private futexes for semaphores, unless they are initialized with pshared != 0.
Change-Id: I534e36a7171cd37037ae03b910ba71ea6968286d
Note: previously, sem_init() would return an error if pshared != 0.
2010-06-08 17:04:49 -07:00
Jean-Baptiste Queru
a8a2148863 resolved conflicts for merge of 7b6e6fa5 to kraken
Change-Id: I2b9b80a7fa32c56be2b85ff8be0d6e7ac1848afe
2010-06-03 15:05:04 -07:00
The Android Open Source Project
7b6e6fa572 merge from open-source master
Change-Id: Ib7fc9c6f79f9b13e2175da137005d8968ea85eaf
2010-06-03 14:39:20 -07:00
Andy McFadden
fcd00ebbdf Atomic/SMP update, part 3.
Update ARM atomic ops to use LDREX/STREX.  Stripped out #if 0 chunk.

Insert explicit memory barriers in pthread and semaphore code.

For bug 2721865.

Change-Id: I0f153b797753a655702d8be41679273d1d5d6ae7
2010-05-28 16:12:01 -07:00
André Goddard Rosa
78c1c04ced pthread: introduce pthread_setname_np() as a mean to give names to threads
... so that each cloned process at the kernel level can be named
independently. Tools like 'top' can display the CPU/memory statistics
for each process's thread if "Show Threads" mode is on.

With this function in place, we can convert dalvik/Thread.c setThreadName()
function over this function. This feature ought to be provided by the
underlying C library and not coded directly in Dalvik.

Change-Id: Ifa997665dbaa114e0b126f8c667708be9a4137fd
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-05-19 23:17:16 -03:00
David 'Digit' Turner
8a1d2cf142 Add pthread_rwlock_t implementation to the C library (DO NOT MERGE)
Change-Id: I756d8c26afc37cd7b71117ddbaa02a2cb40fdecb
2010-05-19 14:53:18 -07:00
The Android Open Source Project
f450fa5f99 merge from open-source master
Change-Id: If02d33af51017dbd85e91c79ac2e848eda6cf253
2010-05-03 15:33:05 -07:00
David Turner
0be7eda75a Merge "Fix log channel initialization at bionic/logd_write.c." 2010-05-01 15:31:39 -07:00
André Goddard Rosa
5751c54bf1 bionic: add missing NULL check from memory allocation on record_backtrace()
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>

Change-Id: I739c63c5a7344fff1775580044dc647edf246ebf
2010-04-29 07:37:42 -07:00
The Android Open Source Project
95faecefde merge from open-source master
Change-Id: If77618a329fc7b497c44c2585e644bc50e7e1406
2010-04-08 11:11:53 -07:00
André Goddard Rosa
350bb359fa bionic: fix memory leak in get_malloc_leak_info() error path
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-03-29 21:21:26 -03:00
André Goddard Rosa
3f61212781 bionic: clear only the part of the buffer which is not overwritten afterward
Change-Id: I5ddd93f0557e5a7401460dc9fc8a55b330a79c3a
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-03-28 21:32:36 -03:00
David 'Digit' Turner
5207d78c32 Fix typo that broke recursive mutexes implementation.
Change-Id: I832901604b487c6a50304c311b5ba135e153530d
2010-03-23 05:30:55 -07:00
David 'Digit' Turner
b5e4a41606 pthread: Use private futexes by default in condition variables
Now that the system properly uses shared condvars when needed, we
can enable the use of private futexes for them too.

Change-Id: Icf8351fc0a2309f764cba45c65bc3af047720cdf
2010-03-22 17:31:50 -07:00
The Android Open Source Project
377d4c979d merge from open-source master
Change-Id: I70266ee8c520b216773f267e46c8273d2334c31d
2010-03-22 15:55:09 -07:00
David 'Digit' Turner
88f06cd84a Use private futexes for pthread_mutex_t.
This does not change the implementation of conditional variables
since we're waiting for other system components to properly use
pthread_condattr_init/setpshared before that.

Also remove an obsolete x86 source file.

Change-Id: Ia3e3fbac35b87a534fb04d4381c3c66b975bc8f7
2010-03-18 17:13:41 -07:00
David Turner
1825fb5d5f Merge "bionic: on pthread_join(), avoid extra check in case we find the thread" 2010-03-18 16:42:49 -07:00
David Turner
c0e464268d Merge "bionic: ftell() returns a long, not an int" 2010-03-18 16:35:42 -07:00
David 'Digit' Turner
ee7b077abf Add pthread_condattr_init/destroy/setpshared/getpshared
Note that this does not change the implementation of conditional variables
which still use shared futexes, independent on the flags being selected.

This will be fixed in a later patch, once our system is modified to use
pthread_condattr_setpshared(attr, PTHREAD_PROCESS_SHARED) properly.

Change-Id: I935de50964cd41f97a13dbfd6626d3407b0406c3
2010-03-18 14:07:42 -07:00
David 'Digit' Turner
40e6b82286 Fix indentation in pthread mutex implementation.
This is preliminary work to simplify later changes to support
private futexes.

Change-Id: I06750936a93747a5e3f5a10228cbdc29e39c528c
2010-03-17 11:25:46 -07:00
David Turner
a9c41a8e0a Merge "bionic: remove unneeded variable from chk_realloc()" 2010-03-16 17:26:44 -07:00
Fabrice Di Meglio
8641833b62 Revert "bionic: pthread: use private futexes by default for mutexes and condvars"
This reverts commit ba9c6f0989.
2010-03-11 14:47:47 -08:00
David 'Digit' Turner
ba9c6f0989 bionic: pthread: use private futexes by default for mutexes and condvars
Private futexes are a recent kernel addition: faster futexes that cannot be
shared between processes. This patch uses them by default, unless the PROCESS_SHARED
attribute flag is used when creating a mutex and/or conditional variable.

Also introduces pthread_condattr_init/destroy/setpshared/getpshared.

Change-Id: I3a0e2116f467072b046524cb5babc00e41057a53
2010-03-11 11:48:38 -08:00
Mike Chan
9f6915631b bonic: libc: cpuacct support for setuid functions
Any of the setuid functions now updates /acct/uid/ with its own tid
before changing users. This is so we can properly account for cpu time
per uid.

Change-Id: I34186cf4d5228cac8439e582a9e26c01ef3011e4
Signed-off-by: Mike Chan <mike@android.com>
2010-03-02 18:18:04 -08:00
David 'Digit' Turner
8f8b5310d2 Fix pthread_sigmask() to return correct error values.
Before that, it returned -1 on error and set errno (not Posix)
After the patch, it returns the error code and leaves errno untouched.
2010-03-01 11:30:40 -08:00
Vladimir Chtchetkine
b55462328f Merge "Merge memory checking functionality from sandbox" 2010-02-17 13:43:15 -08:00
Vladimir Chtchetkine
75fba6888a Merge memory checking functionality from sandbox
Change-Id: I304c789a752c9f4af4944ca14b9bf1e7644da15a
2010-02-16 11:43:18 -08:00
David 'Digit' Turner
4f920f685b Fix sem_post() behaviour to wake up multiple waiting threads. 2010-02-12 12:50:32 -08:00