Commit graph

6986 commits

Author SHA1 Message Date
Pierre Imai
ce3101f021 Merge "Ignore unreliable DNS servers." 2016-04-05 03:44:36 +00:00
Pierre Imai
6b3f0d65f2 Ignore unreliable DNS servers.
Collect statistics about DNS query success state and delay. Ignore
servers that have been tried at least five times and have a success rate
of < 0.25. Retry these servers once every 180s.

Bug: 25731675
Change-Id: I78e24f43e388dca82fb81835e1796f4c7dce8da3
2016-04-05 11:42:43 +09:00
Elliott Hughes
5b528c0832 Merge "Make it harder to use a broken legacy function by accident." 2016-04-05 00:36:08 +00:00
Elliott Hughes
df143f8576 Add POSIX getsubopt(3).
Bug: http://b/27952303
Change-Id: I8a816477545dadcbd5c055714e76263574446b6f
2016-04-04 17:34:04 -07:00
Yabin Cui
9a30714c87 Merge "Format code to calculate thread stack and signal stack." 2016-04-05 00:08:05 +00:00
Greg Hackmann
5375bf6398 Add SysV signal handling
Implement the legacy SysV signal handling functions sighold(),
sigignore(), sigpause(), sigrelse(), and sigset() in terms of the newer
POSIX signal APIs.  As of POSIX 2013 the SysV signal APIs are deprecated
but still required.

Change-Id: I4ca40e3d706605a7d1a30dc76c78b2b24586387d
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-04-04 16:33:29 -07:00
Yabin Cui
ff624c2c17 Format code to calculate thread stack and signal stack.
The code to calculate thread stack and signal stack looks weird:
the thread stack size and signal stack size are related with
each other on 32-bit mode, but not on 64-bit mode. So change the
code to make the logic more resonable. This doesn't change anything
as we have defined SIGSTKSZ to 16K on arm64.

Bug: 28005110

Change-Id: I04d2488cfb96ee7e2d894d062c66cef950fec418
2016-04-04 16:19:39 -07:00
Elliott Hughes
5db4b6e5de Make it harder to use a broken legacy function by accident.
This function only exists for backwards compatibility, so leave it as it was.

Bug: http://b/26944282
Change-Id: I31973d1402660933103ee2d815649ab9569e4dfc
2016-04-04 16:15:37 -07:00
Dan Willemsen
be45b22a51 Update Android.bp with recent Android.mk changes
This ports Idb3d445e053c44180773f59774df19b324f6817f to Android.bp

Change-Id: Id5cdb450330792810b8eb61b3cab115ef046e55d
2016-04-04 13:20:31 -07:00
Elliott Hughes
afe835d540 Move math headers in with the other headers.
Keeping them separate is a pain for the NDK, and doesn't help the platform.

Change-Id: I96b8beef307d4a956e9c0a899ad9315adc502582
2016-04-02 08:36:33 -07:00
Elliott Hughes
1e8958448a Merge "Ensure only mips is using GCC to build bionic." 2016-04-01 20:30:11 +00:00
Yabin Cui
af39abdef5 Merge "Check current pid at libc initialization for 32-bit build." 2016-04-01 17:56:33 +00:00
Elliott Hughes
cf73e00dde Ensure only mips is using GCC to build bionic.
MIPS still have ld128 and 16-bit atomics issues with clang, so we can't
just remove this yet.

Bug: http://b/25291096
Change-Id: I2645ebf3af04e1a4008d70da780c04240e3d7a85
2016-04-01 10:54:27 -07:00
Elliott Hughes
cd3abe38ef Tell GCC that sometimes we have to build deprecated functions.
We're the C library. Nothing could be more deprecated.

bionic/libc/bionic/pthread_cond.cpp:243:10: error: 'int pthread_cond_timedwait_relative_np(pthread_cond_t*, pthread_mutex_t*, const timespec*)' is deprecated (declared at bionic/libc/bionic/pthread_cond.cpp:227): use pthread_cond_timedwait instead [-Werror=deprecated-declarations]
   return pthread_cond_timedwait_relative_np(cond_interface, mutex, &ts);
          ^
bionic/libc/bionic/pthread_cond.cpp:243:71: error: 'int pthread_cond_timedwait_relative_np(pthread_cond_t*, pthread_mutex_t*, const timespec*)' is deprecated (declared at bionic/libc/bionic/pthread_cond.cpp:227): use pthread_cond_timedwait instead [-Werror=deprecated-declarations]
   return pthread_cond_timedwait_relative_np(cond_interface, mutex, &ts);
                                                                       ^

Change-Id: Idb3d445e053c44180773f59774df19b324f6817f
2016-04-01 10:25:52 -07:00
Elliott Hughes
e9daecf74b Merge "Stop defining HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE." 2016-04-01 16:43:42 +00:00
Elliott Hughes
5dd13d09c1 Differentiate the MNTTYPE_* and MNTOPT_* constants.
Bug: http://b/27952303
Change-Id: I926593c16143f76b21a65af7f6e1979d0fb44cac
2016-03-31 18:20:01 -07:00
Elliott Hughes
1f1a51aecd Add a few missing types and constants to headers.
This (and other stuff still to come) prevented xfstests from building out
of the box.

Bug: http://b/27952303
Change-Id: Id38fd37386d43fc351c56dca18785a465e3e6145
2016-03-31 17:05:30 -07:00
Yabin Cui
36733fc4c1 Check current pid at libc initialization for 32-bit build.
Although there is a test pthread.pthread_mutex_owner_tid_limit
to check pid_max, but bionic-unit-tests hangs before reaching
that test. So abort at libc initialization if not able to reach
the test when running bionic-unit-tests32. It is more friendly
for debugging.

Bug: 24016357
Change-Id: Ia70c2e36fd8a3a040d41ea5722c7b48a6134e102
2016-03-30 16:45:08 -07:00
Elliott Hughes
96583dcf95 Stop defining HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE.
Bug: http://b/27918161
Change-Id: I21d4dfa4636aa06a93b3c8a215113f66f37f0bc7
2016-03-30 10:33:54 -07:00
Josh Gao
eaf50be332 Merge "Add a checksum to jmp_buf on mips and mips64." 2016-03-30 02:27:00 +00:00
Josh Gao
a42789f9d2 Merge changes from topic 'setjmp_checksum_x86'
* changes:
  Add a checksum to jmp_buf on x86_64.
  Delete lies from x86_64 setjmp implementation.
  Add a checksum to jmp_buf on x86.
2016-03-30 00:58:30 +00:00
Josh Gao
686e5f6f69 Add a checksum to jmp_buf on x86_64.
Bug: http://b/27856501
Bug: http://b/27417786
Change-Id: I541f5a7ce4972ef56b3f69e73927ca7df362609a
2016-03-29 17:28:32 -07:00
Josh Gao
c244fcb8a3 Delete lies from x86_64 setjmp implementation.
Previously, the implementation of setjmp on x86_64 claimed that
sigprocmask would write to two longs' worth of bytes.

Bug: http://b/27856501
Change-Id: I9f32b40ac773a0cd91a976aace5bfba6e67fb0f8
2016-03-29 17:28:32 -07:00
Josh Gao
9260785393 Add a checksum to jmp_buf on x86.
Bug: http://b/27856501
Bug: http://b/27417786
Change-Id: Id5a0a81fc38e311bff678cbc7dc2219bc0074503
2016-03-29 17:28:32 -07:00
Dan Willemsen
23aae1ce30 Update Android.bp with getdomainname
Change-Id: I32383162acd16430089708fdce8927be43d1bc5a
2016-03-29 15:21:38 -07:00
Greg Hackmann
d15dfb2ff5 clock_nanosleep: add CLOCK_THREAD_CPUTIME_ID special case
POSIX makes "the CPU-time clock of the calling thread" (i.e.,
CLOCK_THREAD_CPUTIME_ID) a special case which returns EINVAL instead of
ENOTSUP.

However, the clock_nanosleep syscall treats this clock just like any
other, and returns -EOPNOTSUPP to indicate an unimplemented nanosleep
handler.  So we need to handle this ourselves in userspace.

This change fixes the LTP clock_nanosleep01 testcase.

Change-Id: If3bed940d276834bcd114d8c17f96197e9384711
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-28 10:29:16 -07:00
Predrag Blagojevic
3299590dfe Add a checksum to jmp_buf on mips and mips64.
Make it easier to diagnose applications mucking with the contents of
jmp_buf by checksumming its contents.

Bug: http://b/27417786
Change-Id: I473bc2871dece23a9b9d02481945246160d671c6
2016-03-28 14:54:49 +00:00
Nick Kralevich
dbf2e19281 fixup x86 setdomainname.S
Both be91052932 and
e2faf07d65 were submitted about
two days ago. The former changed how the syscalls stubs were
generated, but the latter was submitted using the old stub
format.

Use the new stub format for setdomainname.S

Change-Id: I578acd7053f57a275f6831dd2404ef04826c578e
2016-03-27 14:52:58 -07:00
Greg Hackmann
d132099e05 Merge "Add hasmntopt(3)" 2016-03-25 22:43:01 +00:00
Elliott Hughes
d81143df71 Merge "libc: implement kernel vdso syscalls for i386" 2016-03-25 22:20:42 +00:00
Greg Hackmann
76640d5555 Merge "Add {get,set}domainname(2)" 2016-03-25 22:02:07 +00:00
Greg Hackmann
3679ade533 Add hasmntopt(3)
bionic has the Linux-specific mntent.h but is missing hasmntopt().

Change-Id: I0ab7b83626c969704add4e64b37a6fc715d4a723
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-25 14:16:58 -07:00
Greg Hackmann
e2faf07d65 Add {get,set}domainname(2)
{get,set}domainname aren't in POSIX but are widely-implemented
extensions.

The Linux kernel provides a setdomainname syscall but not a symmetric
getdomainname syscall, since it expects userspace to get the domain name
from uname(2).

Change-Id: I96726c242f4bb646c130b361688328b0b97269a0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-25 14:16:58 -07:00
Mingwei Shi
be91052932 libc: implement kernel vdso syscalls for i386
This patch uses __kernel_vsyscall instead of "int 0x80"
as the syscall entry point. AT_SYSINFO points to
an adapter to mask the arch specific difference and gives a
performance boost on i386 architecture.

Change-ID: Ib340c604d02c6c25714a95793737e3cfdc3fc5d7
Signed-off-by: Mingwei Shi <mingwei.shi@intel.com>
2016-03-25 14:10:05 -07:00
Greg Hackmann
2846ae70fb Merge "epoll_create: reject size <= 0" 2016-03-25 19:35:01 +00:00
Greg Hackmann
61cb584f9f Merge "clone: check for NULL child stack" 2016-03-25 19:34:44 +00:00
Elliott Hughes
204990cc83 Fix x86 __memset_chk.
The stack offsets assumed we'd pushed %ebx. Unlike x86-64 we can't fall
through, but we can avoid repeating work we've already done.

Change-Id: I7e5f9be50983ed6178dd0c0534042da7ea30ad0c
2016-03-24 22:34:47 -07:00
Greg Hackmann
a03c62b469 epoll_create: reject size <= 0
Even though the size parameter to epoll_create(2) is (otherwise) unused,
passing in size <= 0 is explicitly documented as an error.

This change fixes the LTP epoll01 testcase.

Change-Id: I044a38be823c2fa956b57e77cc66571dfae8a4bb
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-24 16:37:20 -07:00
Greg Hackmann
fb23fa3046 clone: check for NULL child stack
The clone syscall accepts NULL child stacks, interpreting this to mean
the child gets a copy of the parent's stack with copy-on-write
semantics.  However clone(2) is explicitly documented to treat this an
an error.

"Fortunately" every architecture's __bionic_clone implementation pushes
something onto the child stack before making the clone syscall.  So we
know fixing this won't break legacy apps, because any app that tried
using a NULL child stack would have died with SIGSEGV.

This change fixes the LTP clone04 testcase.

Change-Id: I663b34f34bc8dad2aa405c46e4eed4418cccca0d
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-24 16:37:20 -07:00
Elliott Hughes
cc78b252d1 Remove the __USE_GNU guard from pthread_setname_np again.
Caused build breakage, but not spotted by TreeHugger:

  external/libnfc-nxp/Linux_x86/phDal4Nfc.c:737:5: error: implicit declaration of function 'pthread_setname_np' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    pthread_setname_np(pthread_self(), "reader");
    ^

Nice file name.

Change-Id: I102e55718babf4e4f2f2c64066c6a83ed3ac86d3
2016-03-23 20:26:35 -07:00
Elliott Hughes
63322aa555 Merge "Add pthread_getname_np." 2016-03-24 02:47:10 +00:00
Elliott Hughes
725b2a96a7 Add pthread_getname_np.
Also guard both these GNU extensions with _GNU_SOURCE.

Also improve the tests to test each case on both the current thread and
another thread, since the code paths are totally different.

Bug: http://b/27810459
Change-Id: I72b05bca5c5b6ca8ba4585b8edfb716a1c252f92
2016-03-23 17:40:25 -07:00
Greg Hackmann
e5c872ffb7 genversion-scripts: fix script name in autogenerated comment
Change-Id: I2a304818cfc54d08a08d2e621e4cf74e7ce465dd
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-23 16:25:42 -07:00
Christopher Ferris
5f1de52eca Merge "Fix race in malloc debug option free_track." 2016-03-17 17:52:55 +00:00
Christopher Ferris
d0919623a2 Fix race in malloc debug option free_track.
The free track mechanism could fail if, at the same time a free occurs,
another thread is trying to free and verify the same allocation. This
doesn't work if the freed allocation is added to the list and we still
do work on it. The fix is to only add to the free list when we are done
with the allocation.

Also fix a problem where the usable size is computed incorrectly because
two of the arguments where reversed.

In addition, add a check that the allocation being verified has the correct
tag before trying to check the body of the allocation.

Add a test to catch the original failure.

Add a test for the tag being different.

Bug: 27601650
Change-Id: Ie9200677d066255b8e668a48422f23f909f4ddee
2016-03-16 17:38:08 -07:00
Douglas Leung
f3b9c89d3a Fix bug where t9 is not correct when __memset_chk_fail is called.
t9 is used to calculate gp at the start of __memset_chk_fail.

Change-Id: Ief5018699e060afa691bfc1d861abd5e463ab80c
2016-03-16 17:02:17 -07:00
Elliott Hughes
545afa16bb Fix PTHREAD_THREADS_MAX.
We don't have a compile-time limit on the number of threads,
and we don't have a definite run-time limit either.

Bug: http://b/27617302
Change-Id: I6a6fe083e7b655d24eb9e7ef7f3e0280d483080b
2016-03-15 17:23:12 -07:00
Christopher Ferris
a4b1425275 Fix problem where unknown option is not an error.
If the first option is found, then any unknown options are simply
ignored, but do not produce an error. Fixed this so that each
option found is actually verified to exist.

Bug: 27620263
Change-Id: If58732df3285eeae72188162c505e0e202fada8c
2016-03-14 15:34:22 -07:00
Christopher Ferris
0e00c168ce Merge "Init functions after debug malloc succeeds." 2016-03-12 21:15:34 +00:00
Christopher Ferris
20f2c1ebd5 Init functions after debug malloc succeeds.
Do not initialize all of the global function pointers associated with
debug malloc until the initialization has completed correctly.

Bug: 27600760
Change-Id: I0621b54bc2d9fab63805d7992d384e550d6fed2a
2016-03-11 12:27:02 -08:00
Colin Cross
7877df66c2 malloc_debug: fix multiplication overflow in debug_calloc
The over flow check for nmemb * bytes in debug_calloc is incorrect,
use the builtin overflow functions to check for multiplication and
addition overflow.

Change-Id: I3f1c13102621bc5380be1f69caa88dba2118f3cb
(cherry picked from commit 239838608d)
2016-03-10 14:53:02 -08:00
Colin Cross
9567c7b82c malloc_debug: round 0 byte allocations up to 1 byte
0 byte allocations can cause problems if they are immediately followed
by another allocation with no header, as both allocations will have the
same address.  Treat 0 byte allocations as 1 byte allocations so that
debug_iterate will return separate addresses for them.

Bug: 27578580
Change-Id: Ia8dc3481fa7062391e9b3ae58a36e8d47e7ee557
(cherry picked from commit 15af478080)
2016-03-10 14:53:02 -08:00
Colin Cross
baa7c6f307 malloc_debug: iterate: use usable_size
malloc_iterate with malloc debug enabled was returning allocation sizes
using the requested size instead of usable size.  If anything wrote
pointers above the requested size but below the usable size, those
pointers would be invisible to libmemunreachable and referenced
allocations could be reported as a leak.

Bug: 27107100
Change-Id: I6b19fd631f68ce93b3aee408cc3d296ec457bd01
(cherry picked from commit b23c6606d2)
2016-03-10 14:53:02 -08:00
Elliott Hughes
ffd19ee64d Merge "Improve and fix the stack-protector tests." 2016-03-10 16:12:27 +00:00
Elliott Hughes
fc69a8ad5f Improve and fix the stack-protector tests.
Bug: http://b/26888853
Change-Id: I505dbf7d5934f7247fb639f55dd6a9341df3947b
2016-03-09 14:50:03 -08:00
Erik Kline
7bbb181bf0 Don't leak sockets if setsockopt() or fchown() fail.
Change-Id: Idcf8c08ff50d21c3a04b7ef80c4044f3f9762f2b
2016-03-09 12:11:13 +09:00
Elliott Hughes
2bf5332f23 Minor clock_getcpuclockid optimization.
Don't ask the kernel to copy data to userspace if we don't need it.
(Noticed while cleaning up sysconf to not call clock_getres.)

Change-Id: Icc0f7559775b8a2dcefe638ce831d06b75d67122
2016-03-07 11:54:02 -08:00
Josh Gao
ba2232d013 Merge "forkpty: set the output fd to -1 on the slave side." 2016-03-05 03:04:37 +00:00
Elliott Hughes
d2b8de2cd1 Don't call clock_getres in sysconf.
There are a hundred other reasons why we can't run on kernels old enough
to not have all the clocks covered by sysconf.

This was causing trouble for jemalloc 4.1.0 in a seccomp-constrained process
because jemalloc 4.1.0 introduced a call to sysconf that caused us to make
clock_getres syscalls for the first time, leading to SIGSYS.

Bug: http://b/27408522
Change-Id: I2eb6986d871bc03cbef278e5617734409c39e057
2016-03-04 18:28:53 -08:00
Josh Gao
6d7c1ee9ff forkpty: set the output fd to -1 on the slave side.
glibc, FreeBSD, OpenBSD, and Darwin all just leave the fd unchanged and
possibly uninitialized. Setting it to -1 seems friendlier, though.

Bug: http://b/27506278
Change-Id: I7acdc8eecbea4404d5fb4ba0b4d572245a323886
2016-03-04 18:04:41 -08:00
Douglas Leung
29d4b71426 Add __memset_chk assembler for mips32 and mips64.
Change-Id: I365b1f345c695850c30ccb1a9f56f254ce182000
2016-03-04 15:15:00 -08:00
Elliott Hughes
728e0e9b97 Merge "Add x86 __memset_chk assembler." 2016-03-04 16:28:10 +00:00
Elliott Hughes
7d188ce0fe Merge "Fix x86-64 __memset_chk." 2016-03-04 03:12:35 +00:00
Elliott Hughes
a80ddc8a34 Fix x86-64 __memset_chk.
I can only assume I was testing the 32-bit implementation when I claimed
this worked. While improving the 32-bit code I realized that I'd used
signed comparisons instead of unsigned, and came back to find that the
64-bit code didn't work.

By way of apology, make x86-64 the first architecture where __memset_chk
falls through to memset.

Change-Id: I54d9eee5349b6a2abb2ce81e161fdcde09556561
2016-03-03 16:46:25 -08:00
Elliott Hughes
81d6a18c69 Add x86 __memset_chk assembler.
Change-Id: Ic6732f761ea8a41f70d5ff59d47ad38417d17cc2
2016-03-03 16:10:33 -08:00
Dan Willemsen
a27d8c3094 Update Android.bp with recent *.mk changes
Change-Id: I01acce3b0018d838c4765881c19f5f009721370f
2016-03-03 15:41:14 -08:00
Elliott Hughes
f3b42e5ae7 Merge "Clean up bcopy cruft." 2016-03-03 22:24:51 +00:00
Elliott Hughes
ff9bda7201 Merge "Mandate optimized assembler for x86-64 __memset_chk." 2016-03-03 22:18:46 +00:00
Josh Gao
19ca2fe82f Merge changes I17c22dc2,I9989e2ea
* changes:
  Add a checksum to jmp_buf on AArch64.
  Add a checksum to jmp_buf on ARM.
2016-03-03 22:02:37 +00:00
Josh Gao
0c3655a864 Add a checksum to jmp_buf on AArch64.
Bug: http://b/27417786
Change-Id: I17c22dc28a46dd6b678b449b506b0da978f3793e
2016-03-03 12:45:08 -08:00
Josh Gao
a4c69137c6 Add a checksum to jmp_buf on ARM.
Make it easier to diagnose applications mucking with the contents of
jmp_buf by checksumming its contents.

Bug: http://b/27417786
Change-Id: I9989e2ea3979a36ae0bc4c9e1bacafddbacc731b
2016-03-03 12:45:08 -08:00
Elliott Hughes
bed110af26 Clean up bcopy cruft.
Also remove some generic x86 assembler that's never built.

Change-Id: Ic126de2eee646b5ba2b6ee549679ba90d67a48bb
2016-03-03 10:41:42 -08:00
Elliott Hughes
01d5b946ac Remove optimized code for bzero, which was removed from POSIX in 2008.
I'll come back for the last bcopy remnant...

Bug: http://b/26407170
Change-Id: Iabfeb95fc8a4b4b3992e3cc209ec5221040e7c26
2016-03-02 17:21:07 -08:00
Elliott Hughes
61c95fe52d Mandate optimized assembler for x86-64 __memset_chk.
Change-Id: I4d6b452f3cf850d405e8f5d7da01d432603e606b
2016-03-02 16:39:29 -08:00
Elliott Hughes
784609317d Mandate optimized __memset_chk for arm and arm64.
This involves actually implementing assembler __memset_chk for arm64,
but that's easily done.

Obviously I'd like this for all architectures (and all the string functions),
but this is low-hanging fruit...

Change-Id: I70ec48c91aafd1f0feb974a2555c51611de9ef82
2016-03-02 11:58:41 -08:00
Elliott Hughes
2332d52439 Merge "Improve diagnostics from the assembler __memcpy_chk routines." 2016-03-02 19:13:03 +00:00
Elliott Hughes
ef925e50d3 Fix getifaddrs' handling of point-to-point interfaces.
Also remove an if that implied that IFA_BROADCAST is a possibility for
AF_INET6.

The existing tests fail if you have a point-to-point interface configured,
so no new test necessary.

Bug: http://b/27442503
Change-Id: I4c5823b32204ae6c15527853414c2a0cef320b53
2016-03-01 20:05:59 -08:00
Elliott Hughes
3c6016f04a Improve diagnostics from the assembler __memcpy_chk routines.
Change-Id: Iec16c92ed80beee505cba2121ea33e3550197b02
2016-03-01 14:45:58 -08:00
Elliott Hughes
c199690b5f Merge "Improve diagnostics from the assembler __memset_chk routines." 2016-03-01 21:25:06 +00:00
Elliott Hughes
62e59646f8 Improve diagnostics from the assembler __memset_chk routines.
Change-Id: Ic165043ab8cd5e16866b3e11cfba960514cbdc57
2016-03-01 12:46:47 -08:00
Lazar Trsic
375a915c37 Update libgcc_compat.c file for mips32 arch
Contains complete list of libgcc references.

Change-Id: If6b8000dcefa72036a025ebbe59f51e93fe57e98
2016-03-01 15:22:17 +01:00
Pierre Imai
2de7983470 Merge "Copy the entire zero-separated DNS seach domain string." 2016-03-01 08:15:03 +00:00
Christopher Ferris
6fa50a292e Merge "Move hard-coded values to constants." 2016-02-29 19:22:59 +00:00
Dan Willemsen
879cec2770 Update Android.bp with recent Android.mk changes
Change-Id: If9777e9ece6de1bc00c3ef86724c7bd4d437aaca
2016-02-29 10:37:56 -08:00
Pierre Imai
0967fc7e59 Copy the entire zero-separated DNS seach domain string.
The DNS search string contains zeros as domain separator. The resolver
code erroneously used strlcpy(), which resulted in only the first domain
to be copied. The code uses pointers into this string to access the
individual domains. Since the structure is zero-initialized, this bug only
resulted in zero-length domains instead of accessing unitialized memory.

BUG: 27312811
Change-Id: Ia9d066c405dfcc5e82d6766d93ead2ce574e7b0d
2016-02-29 16:50:38 +09:00
Elliott Hughes
0f67d5ffa4 Create logging sockets with SOCK_NONBLOCK...
...rather than calling fcntl on them directly after creation.

Bug: https://code.google.com/p/android/issues/detail?id=201440
Change-Id: Ia3941b7645455d69620b1a361902df009b5da2c5
2016-02-27 19:18:41 -08:00
Elliott Hughes
31adf6cd38 Merge "Improve FORTIFY failure diagnostics." 2016-02-28 00:30:31 +00:00
Elliott Hughes
b83d6747fa Improve FORTIFY failure diagnostics.
Our FORTIFY _chk functions' implementations were very repetitive and verbose
but not very helpful. We'd also screwed up and put the SSIZE_MAX checks where
they would never fire unless you actually had a buffer as large as half your
address space, which probably doesn't happen very often.

Factor out the duplication and take the opportunity to actually show details
like how big the overrun buffer was, or by how much it was overrun.

Also remove the obsolete FORTIFY event logging.

Also remove the unused __libc_fatal_no_abort.

This change doesn't improve the diagnostics from the optimized assembler
implementations.

Change-Id: I176a90701395404d50975b547a00bd2c654e1252
2016-02-26 22:06:17 -08:00
Christopher Ferris
549e52200b Move hard-coded values to constants.
Change all of the hard-coded config values to be defined constants.
Also make sure to use these constants in the usage output.

Bug: 26739265
Change-Id: I597a6d71279a2df9cc7e98c42ac70224261bac99
2016-02-26 17:02:17 -08:00
Neil Fuller
eb727252f2 Merge "Update timezone data to 2016a" 2016-02-26 11:23:28 +00:00
Elliott Hughes
f86c4494ff If you're going to use memset...
...you'd better #include <string.h>.

Change-Id: I83e0877f4151fc764588e2d876e66d7712d41f61
2016-02-25 22:05:28 -08:00
Elliott Hughes
2c6c95348c GCC doesn't like {}, and clang doesn't like {0}...
...so memset it is, then.

I'll be glad when GCC is dead and we can use "= {}" like it's the 21st century.

Change-Id: I28d820d3926ac9bf44bf7c1e89e184726c840391
2016-02-25 21:51:50 -08:00
Elliott Hughes
d07d77e399 Merge "Fix a structure initialisation in pthread_exit()." 2016-02-26 04:59:51 +00:00
Anton Kirilov
6bd5cf60fa Fix a structure initialisation in pthread_exit().
The purpose of this change is to silence Valgrind's warning about a
syscall parameter pointing to uninitialised bytes.

Change-Id: I2737235f9ac288dbc8ec4be0c6f1cef181c9b7d7
2016-02-25 20:49:15 -08:00
Dimitry Ivanov
19acb698e8 [MIPS] Add __popcountsi2 to libgcc_compat.c
Also removed outdated genlibgcc_compat.py script
and references to it.

Bug: http://b/27340856
Change-Id: I7eef362364078867c60a27e72abba515f08b6651
2016-02-25 14:28:45 -08:00
Neil Fuller
92057af535 Update timezone data to 2016a
Changes affecting future time stamps

    America/Cayman will not observe daylight saving this year after all.
    Revert our guess that it would.  (Thanks to Matt Johnson.)

    Asia/Chita switches from +0800 to +0900 on 2016-03-27 at 02:00.
    (Thanks to Alexander Krivenyshev.)

    Asia/Tehran now has DST predictions for the year 2038 and later,
    to be March 21 00:00 to September 21 00:00.  This is likely better
    than predicting no DST, albeit off by a day every now and then.

  Changes affecting past and future time stamps

    America/Metlakatla switched from PST all year to AKST/AKDT on
    2015-11-01 at 02:00.  (Thanks to Steffen Thorsen.)

    America/Santa_Isabel has been removed, and replaced with a
    backward compatibility link to America/Tijuana.  Its contents were
    apparently based on a misreading of Mexican legislation.

  Changes affecting past time stamps

    Asia/Karachi's two transition times in 2002 were off by a minute.
    (Thanks to Matt Johnson.)

Bug: 26833368
(cherry-picked from commit 5408d8f39a)

Change-Id: I568ae45e0b38382507db3c244392ccc2edff29d3
2016-02-25 17:53:37 +00:00
Christopher Ferris
0e2a026579 Fix wrong guard values for 64 bit.
I added the code to force alignments of 8 for 32 bit and 16 for 64 bit,
but I missed a couple of tests that failed due to this change. Fix the
failing tests.

Bug: 26739265
Change-Id: Ice9932d1419e59c07483c4c9fcdb84970844f0a6
2016-02-22 19:14:26 -08:00
Christopher Ferris
f499dc91e7 Fix incorrect size of array.
When using sscanf and "%4s", the array passed in must include space for
a nul terminator.

Bug: 26739265
Change-Id: I0140a6100ca370666ae61689087ba41b4914789d
2016-02-19 18:13:29 -08:00
Colin Cross
d75d4bea54 malloc_debug: reread /proc/pid/maps when entry is missing
Reread /proc/pid/maps on demand in case a new library has been loaded.

Change-Id: Iac8109b3e6a07bf02c38300b21eecabf4bcd54df
2016-02-18 16:09:17 -08:00
Colin Cross
2c75991359 Add backtrace_string and export to libmemunreachable
Add backtrace_string to convert a malloc_debug backtrace to a string.
Also move the backtrace functions to libc_malloc_debug_backtrace so that
libmemunreachable can reuse them.

Change-Id: I5ad67001c0b4d184903c762863a8588181d4873b
2016-02-18 16:09:17 -08:00
Colin Cross
2d4721c0c5 Export malloc_backtrace
Change-Id: Ic1adb4dfd86b9ca698443a36263a3df2c91edda3
2016-02-18 16:09:16 -08:00
Colin Cross
869691c6f7 Export malloc_iterate and friends
Export malloc_iterate, malloc_enable, and malloc_disable to be used by
libmemunreachable.

Change-Id: I08a50349af82a95d096b6b4cbac37ababe4b9b06
2016-02-18 15:05:38 -08:00
Christopher Ferris
4327ae07b9 Merge "Fix cfi directives for memmove/strlcpy." 2016-02-18 18:46:28 +00:00
Elliott Hughes
90ea63a862 Merge "Fix scope ids for link-local IPv6 addresses from getifaddrs(3)." 2016-02-18 18:35:00 +00:00
Christopher Ferris
97b6e131fd Fix cfi directives for memmove/strlcpy.
Bug: 27227225
Change-Id: I47ca82daaadb3ec24cefc3c9aa4df7ed1798aced
2016-02-17 19:17:02 -08:00
Christopher Ferris
de84e51f8c Fix cfi directives in small strncmp case.
Bug: 27227225
Change-Id: Id4f88fe288109a82822ad1b2291858c1c85b0ca7
2016-02-17 16:34:02 -08:00
Elliott Hughes
7dac8b8aab Fix scope ids for link-local IPv6 addresses from getifaddrs(3).
Bug: http://b/27219454
Change-Id: I7a166ff5553565f7afdab18dd2c703af4d475ab4
2016-02-17 14:38:09 -08:00
Colin Cross
598cb89790 Merge "malloc_debug: reset TrackData mutex after fork" 2016-02-17 20:38:02 +00:00
Christopher Ferris
249fefbda0 Merge "Fix the default alignment of the allocations." 2016-02-13 01:37:06 +00:00
Christopher Ferris
72df6708c8 Fix the default alignment of the allocations.
In order to enforce this constraint:

The pointer returned if the allocation succeeds shall be suitably
aligned so that it may be assigned to a pointer to any type of object
and then used to access such an object in the space allocated.

Force all allocations on 32 bit systems to have 8 byte alignment,
and all allocations on 64 bit systems to have 16 byte alignment.

Add a test to verify that the allocator returns the correct alignments.

Bug: 26739265
Change-Id: I9af53279617408676b94e4ec6481b3ed7ffafc6a
2016-02-12 17:30:30 -08:00
Colin Cross
7a28a3cf1f malloc_debug: reset TrackData mutex after fork
Add a pthread_atfork handler to malloc_debug to lock the TrackData mutex
during fork and reset it in the child.  Ensures that the TrackData is
consistent when forking from a multi-threaded process, and that the
mutex is in a defined state in the child.

Change-Id: I0dfed30045a28551217ceac227d33b2e18894932
2016-02-12 16:41:14 -08:00
Elliott Hughes
cac2908b08 Fix regerror(..., nullptr, 0).
Found by passing a bad regular expression to the Google benchmark
code (https://github.com/google/benchmark).

Change-Id: I475db71c25706bbf02091b754acabe8254062f3a
2016-02-12 16:00:53 -08:00
Elliott Hughes
01b85d5df3 Set x86 TLS limit to 0xfffff, not PAGE_SIZE.
Not least because we set limit_in_pages to 1. PAGE_SIZE pages was never
anyone's intention.

Change-Id: Ide867f44a2fb20d4d5d0cd67ced468e8665a0193
2016-02-09 22:44:16 -08:00
Chih-hung Hsieh
4c3cf4ad4d Merge "Enable clang for x86_64 after fp128 fix in clang-2577113." 2016-02-09 01:27:01 +00:00
Chih-Hung Hsieh
63fedd76ad Enable clang for x86_64 after fp128 fix in clang-2577113.
Upstream LLVM fix was included in prebuilt clang-2577113.

BUG: 21899249
Change-Id: Ief3f3e28650c0bbf8749a5e5d26f45c39e15ed62
2016-02-08 17:07:33 -08:00
Elliott Hughes
b4931cee76 Update NOTICE files.
Change-Id: I6c4628534c5842c9835ead1bfff6582c5dce38e3
2016-02-08 17:00:12 -08:00
Mike Frysinger
9c212fc436 Merge "define pw_gecos to pw_passwd for LP32 systems" 2016-02-06 19:29:29 +00:00
Mike Frysinger
ca6af7f4a8 define pw_gecos to pw_passwd for LP32 systems
Since we set both fields to NULL all the time, we can alias the two
fields together on LP32 to provide build-time compatibility.

BUG=24918750
TEST=python now builds for Brillo boards

Change-Id: I3394aea80c9a5288669389f71d0e4132f2157e3c
2016-02-06 09:28:44 -05:00
Christopher Ferris
831c8a5249 Merge "Updated to v4.4.1 kernel headers." 2016-02-06 05:24:53 +00:00
Dan Willemsen
138a11c8a1 Merge "Update Android.bp" 2016-02-06 00:43:13 +00:00
Christopher Ferris
05d08e9716 Updated to v4.4.1 kernel headers.
Small modifications needed to allow compilation with the new headers:

- Manually modify bionic/libc/kernel/uapi/asm-mips/asm/siginfo.h to
  remove the uapi from the include.
- PR_XXX defines are now available for mips, so remove the definition
  from linker_mips.cpp.

Bug: 23789423
Change-Id: I6dc8a03b012426d3a937db15cb24d3a50fab5a8c
2016-02-05 16:03:55 -08:00
Dimitry Ivanov
b90837c3d3 Merge "Add check for pthread_self() when looking up a thread" 2016-02-05 04:29:54 +00:00
Dimitry Ivanov
4bc739a54c Add check for pthread_self() when looking up a thread
Check if thread_id is in fact pthread_self before
locking on g_thread_list_lock in __pthread_internal_find.

The main reason for doing this is not performance but to allow
the linker use raise() which was not working because pthread_kill()
couldn't find pthread_self() thread because the global thread
list is initialized in libc.so and the linker's version of this
list is empty.

Bug: http://b/25867917
Change-Id: I18fe620e8cd465b30f0e1ff45fff32958f3c5c00
2016-02-04 16:48:47 -08:00
Dan Willemsen
3e62171516 Update Android.bp
Also reorders some arch-specific sources to match the order in the
Android.mk system.

Change-Id: Ibde46a7cef9840b759be796ce9ac6618d3b06532
2016-02-03 21:48:08 -08:00
Elliott Hughes
0c485dae70 Add in6addr_any and in6addr_loopback symbols.
Change-Id: I3a90fa448b6bd43321672ba74b84a4e9e8a67738
2016-02-03 14:13:52 -08:00
Elliott Hughes
5f26c6bc91 Really add adjtimex(2), and add clock_adjtime(2) too.
Change-Id: I81fde2ec9fdf787bb19a784ad13df92d33a4f852
2016-02-03 13:19:10 -08:00
Elliott Hughes
f226ee59e0 Add fopen64/freopen64/tmpfile64 aliases.
Our fopen/freopen/tmpfile are already always O_LARGEFILE, but let's add
the aliases for _LARGEFILE_SOURCE compatibility.

Bug: http://b/24807045
Change-Id: I5d99b3ef3c9f27ce70f13313f6a92e96c7f21f80
2016-02-03 11:24:28 -08:00
Elliott Hughes
e4fa6e9cc7 Expose ftello64.
Also add the missing test that would have caught this.

Bug: http://b/24807045
Change-Id: I756a4d825595b52396b15898e3f717156fd1ba2f
2016-02-02 22:39:15 -08:00
Xia Yang
6b45d57739 use GNU C89 extern inline semantics for __size_mul_overflow()
__size_mul_overflow generates warning under following compilation envrionment:

-OX -D_FORTIFY_SOURCE=2 (X=1, 2, 3)

For example:

echo '#include <stdio.h>' | \
prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-gcc \
    -I bionic/libc/arch-arm/include \
    -I bionic/libc/include \
    -I bionic/libc/kernel/uapi \
    -I bionic/libc/kernel/common \
    -I bionic/libc/kernel/uapi/asm-arm \
    -I bionic/libm/include \
    -I bionic/libm/include/arm \
    -I bionic/libc/include \
    -Werror \
    -O1 \
    -D_FORTIFY_SOURCE=2 \
    -c \
    -x c \
    -

bionic/libc/include/stdio.h:360:13: error: '__size_mul_overflow' is
static but used in inline function 'fread' which is not static [-Werror]
         if (__size_mul_overflow(size, count, &total)) {
                          ^

C99 - 6.7.4
"An inline definition of a function with external linkage shall not contain
a definition of a modifiable object with static storage duration, and shall
not contain a reference to an identifier with internal linkage."

As standard does not require compiler to determine when it is safe to
reference an internal function in an external inline function, but instead
delegalizes such reference as a whole, gcc throws a warning for such code
under C99 compilation.  Warning produced by libc header is inhereted widely
and strips the option of using -Werror to track code sanity.

Replace static inline specifier with gnu89 extern inline. Latter "is used
only for inlining. In no case is the function compiled on its own", which
is slightly different from former semantically, but should produce the same
result here.

Change-Id: I6a3374498e5499d110e54468cf9d0d67d2debbe2
2016-02-02 17:28:16 -08:00
Christopher Ferris
701bb65511 Remove the unused TrackHeader structure.
Change-Id: I07ae5de717e1fcfbe5dfe552a531db9f630da622
2016-02-02 13:22:40 -08:00
Christopher Ferris
4821db1b3e Merge "Add better free tracking." 2016-02-02 20:40:36 +00:00
Greg Hackmann
5992e5fb6d Merge changes I8ca219fa,Ia92d35b1
* changes:
  socket.h: update AF_* constants
  Add adjtimex
2016-02-02 18:03:35 +00:00
Greg Hackmann
c7ca8f3a63 socket.h: update AF_* constants
Change-Id: I8ca219fa429ca8d8f872ed1db98275cd1a06f00b
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-02-02 00:28:35 +00:00
Christopher Ferris
7993b80f89 Add better free tracking.
Included in this change:

- Change the tag when a pointer is freed so it's easy to detect if
  an already freed pointer is being used.
- Move the free backtrace out of the header. This backtrace is only
  used under only some circumstances, so no need to allocate space
  in all headers for it.
- Add new option free_track_backtrace_num_frames to specify how many
  frames to record when the free occurs. This removes the dependency
  on the backtrace option to get backtraces.

Bug: 26739265
Change-Id: I76f5209507dcf46af67ada162a7cb2bf282116f2
2016-01-29 15:19:22 -08:00
Shinichiro Hamaji
37591462fa Merge "Tell kati about generated dependencies around crt" 2016-01-29 06:37:46 +00:00
Christopher Ferris
50647711eb Merge "Add min/max values for config values." 2016-01-29 02:31:07 +00:00
Greg Hackmann
3f3f6c526b Add adjtimex
Change-Id: Ia92d35b1851e73c9f157a749dba1e98f68309a8d
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-01-28 13:41:22 -08:00
Shinichiro Hamaji
3bcf094f21 Tell kati about generated dependencies around crt
This was a regression since kati has been introduced. Without
this, touching libc/arch-common/bionic/__dso_handle.h doesn't
let ninja rebuild object files.

Bug: 26839129
Change-Id: Ie9ef4559c0d1ff0910a4d250ea36938b291d15db
2016-01-28 19:39:50 +09:00
Christopher Ferris
166c8535a5 Add min/max values for config values.
This is to only allow realistic values for some of the options.

Bug: 26739265

Change-Id: I172d5401c27e5d638d80f1c93c678c26c4dae0fc
2016-01-27 18:13:09 -08:00
Dimitry Ivanov
fd799baf81 Merge changes I7dc213e9,I2928d682
* changes:
  Hide '__moddi3' symbol for x86 and mips
  Hide '__isthreaded' for lp64 libc.so
2016-01-27 23:36:18 +00:00
Dimitry Ivanov
ffaa2169d7 Hide '__moddi3' symbol for x86 and mips
Bug: http://b/26805673
Change-Id: I7dc213e9f25510a2a74a30e8c43fd7a64cb3dbdb
2016-01-27 15:12:19 -08:00
Dimitry Ivanov
aa2fd0fece Hide '__isthreaded' for lp64 libc.so
Bug: http://b/26805673
Change-Id: I2928d68287894be9f9ae7ed1858af512d8c80a3b
2016-01-27 14:54:36 -08:00
Christopher Ferris
2fc7f9db3d Remove unused file.
This file should have been deleted with the malloc debug rewrite, but
popped back into existence due to a merge conflict.

Change-Id: I74e53daaf3febf650b20e3da5329558ac84c5bcd
2016-01-27 10:58:36 -08:00
Elliott Hughes
955426ef79 Fix a sign extension bug in stdio.
This also lets us test the EOVERFLOW behavior, which pointed out that the
fgetpos/fsetpos return on failure has always been wrong...

Bug: http://b/24807045
Change-Id: I35273eb07c8c9155af858adb27569983397580b6
2016-01-26 18:25:52 -08:00
Tom Cherry
194860a9e6 Merge "Replace snprintf() with __libc_format_buffer()" 2016-01-27 00:09:52 +00:00
Tom Cherry
8352475c75 Replace snprintf() with __libc_format_buffer()
If snprintf() is called from the linker, it may erroneously return a
null string.  The libc internal __libc_format_buffer() does not have
this problem, so it is now used instead.

Bug: 26756577

Change-Id: I37a97e27f59b3c0a087f54a6603cc3aff7f07522
2016-01-26 23:51:01 +00:00
Elliott Hughes
896224aa7f Merge "Implement funopen64." 2016-01-26 23:26:43 +00:00
Elliott Hughes
a449fafc89 Merge "Fix lockf for LP32." 2016-01-26 22:56:36 +00:00
Dimitry Ivanov
3a33b52981 Merge "Move android_ network functions to LIBC_PRIVATE" 2016-01-26 22:47:56 +00:00
Elliott Hughes
03e65eb03b Implement funopen64.
Bug: http://b/24807045
Change-Id: I161920978161389be34b707cc6ce8e05f760d552
2016-01-26 14:45:13 -08:00
Dimitry Ivanov
97cb4fbed2 Move android_ network functions to LIBC_PRIVATE
Make following functions platform-private:
 android_getaddrinfofornet
 android_getaddrinfofornetcontext
 android_gethostbyaddrfornet
 android_gethostbynamefornet

Bug: http://b/26794226
Change-Id: I0855b0b82721e4d24e918508931b4d5587fcae7d
2016-01-26 14:44:00 -08:00
Elliott Hughes
d4ae54f668 Fix lockf for LP32.
Bug: http://b/13077650
Change-Id: Ibbe2d907d23791c908475e0875a5c745ac948813
2016-01-26 14:32:55 -08:00
Elliott Hughes
94bb0fab93 Merge "Support _FILE_OFFSET_BITS=64 for most of <stdio.h>." 2016-01-26 20:51:59 +00:00
Elliott Hughes
d9bb708575 Merge "Implement POSIX lockf." 2016-01-26 20:45:32 +00:00
Elliott Hughes
5704c423c8 Implement POSIX lockf.
This has been requested a few times over the years. This is basically
a very late rebase of https://android-review.googlesource.com/45470
which was abandoned years ago. One addition is that this version has
_FILE_OFFSET_BITS=64 support.

POSIX puts this in <unistd.h>. glibc also has it in <fcntl.h>.

Bug: http://b/13077650
Change-Id: I5862b1dc326e326c01ad92438ecc1578d19ba739
2016-01-26 11:09:44 -08:00
Elliott Hughes
9677fab88c Support _FILE_OFFSET_BITS=64 for most of <stdio.h>.
This doesn't address funopen, but does add fgetpos/fsetpos/fseeko/ftello.

Bug: http://b/24807045
Change-Id: Ibff6f00df5fb699c8e8f13b91a75caf024540b73
2016-01-26 09:14:41 -08:00
Yabin Cui
ca48274298 Revert "Revert "Make sem_wait able to return errno EINTR for sdk > 23.""
This reverts commit 6d51085202.
And add missing bionic_sdk_version.h.

Change-Id: I24cc738b1fd1d26234c52afbc787f5b3c4a9c9cb
2016-01-25 17:39:18 -08:00
Christopher Ferris
126cf324a3 Merge "Fix gcc test issues." 2016-01-26 01:35:03 +00:00
Christopher Ferris
1e185a5056 Fix gcc test issues.
Change-Id: I2b26b779f5198c7c9362a452b971260a8852aa7b
2016-01-25 17:27:40 -08:00
Elliott Hughes
ac67b4eb7c Merge "Revert "Make sem_wait able to return errno EINTR for sdk > 23."" 2016-01-26 00:32:38 +00:00
Dan Albert
6d51085202 Revert "Make sem_wait able to return errno EINTR for sdk > 23."
Broke the build. There's no such file as bionic_sdk_version.h anywhere in the tree.

This reverts commit 892b61d340.

Change-Id: Iec3f4588edfb1d1524bb5f16451fd05dc6ebe44a
2016-01-26 00:20:06 +00:00
Yabin Cui
c96b6e1747 Merge "Make sem_wait able to return errno EINTR for sdk > 23." 2016-01-25 23:39:29 +00:00
Christopher Ferris
e40e429753 Merge "Fix build for gcc." 2016-01-25 22:44:56 +00:00
Christopher Ferris
f2b67b85f5 Fix build for gcc.
Gcc doesn't like the brace object initialization, so make all of
the Feature objects explicit.

Also, no arguments to the error_log macros make gcc unhappy, so add
an option to turn these into warnings. These will be fixed when we
add the explicit _error and _warn log functions.

Change-Id: I35af834dabb5548923e893dd980a751fdebfa13a
2016-01-25 14:36:34 -08:00
Yabin Cui
892b61d340 Make sem_wait able to return errno EINTR for sdk > 23.
Posix standards says sem_wait is interruptible by the delivery
of a signal. To keep compatiblity with old apps, only fix that
in newer sdk versions.

Bug: 26743454

Change-Id: I924cbb436658e3e0f397c922d866ece99b8241a3
2016-01-25 13:44:39 -08:00
Christopher Ferris
0f7631fd92 Merge "Malloc debug rewrite." 2016-01-25 20:48:29 +00:00
Elliott Hughes
e70e0e9267 Move internal FILE flags macros to "local.h" from <stdio.h>.
Bug: http://b/24807045
Change-Id: Ia42ec1907370b4af957ece94a856f71c7ee27cb7
2016-01-25 11:10:47 -08:00
Christopher Ferris
63860cb8fd Malloc debug rewrite.
The major components of the rewrite:

- Completely remove the qemu shared library code. Nobody was using it
  and it appears to have broken at some point.
- Adds the ability to enable/disable different options independently.
- Adds a new option that can enable the backtrace on alloc/free when
  a process gets a specific signal.
- Adds a new way to enable malloc debug. If a special property is
  set, and the process has an environment variable set, then debug
  malloc will be enabled. This allows something that might be
  a derivative of app_process to be started with an environment variable
  being enabled.
- get_malloc_leak_info() used to return one element for each pointer that
  had the exact same backtrace. The new version returns information for
  every one of the pointers with same backtrace. It turns out ddms already
  automatically coalesces these, so the old method simply hid the fact
  that there where multiple pointers with the same amount of backtrace.
- Moved all of the malloc debug specific code into the library.
  Nothing related to the malloc debug data structures remains in libc.
- Removed the calls to the debug malloc cleanup routine. Instead, I
  added an atexit call with the debug malloc cleanup routine. This gets
  around most problems related to the timing of doing the cleanup.

The new properties and environment variables:

libc.debug.malloc.options
  Set by option name (such as "backtrace"). Setting this to a bad value
  will cause a usage statement to be printed to the log.

libc.debug.malloc.program
  Same as before. If this is set, then only the program named will
  be launched with malloc debug enabled. This is not a complete match,
  but if any part of the property is in the program name, malloc debug is
  enabled.

libc.debug.malloc.env_enabled
  If set, then malloc debug is only enabled if the running process has the
  environment variable LIBC_DEBUG_MALLOC_ENABLE set.

Bug: 19145921

Change-Id: I7b0e58cc85cc6d4118173fe1f8627a391b64c0d7
2016-01-25 10:54:21 -08:00
Elliott Hughes
ad9c3f34f7 Merge "Add _seek64 to FILE." 2016-01-25 18:50:41 +00:00
Josh Gao
c650447239 Merge "Remove dlmalloc." 2016-01-25 18:42:55 +00:00
Josh Gao
0ac0cee0d1 Remove dlmalloc.
Bug: http://b/17207577
Change-Id: Ie009badca6deb1f91b27a4340b70cdd6bedff893
2016-01-25 10:14:35 -08:00
Elliott Hughes
023c3071a0 Add _seek64 to FILE.
Move fdopen/fopen/freopen and change them to initialize _seek64 instead
of the legacy _seek. The in-memory streams can stick with _seek for now,
since you're not going to fit a > 4GiB in-memory stream on a 32-bit device
anyway.

Bug: http://b/24807045
Change-Id: I09dcb426817b571415ce24d4d15f364cdda395b3
2016-01-22 23:54:10 -08:00
Elliott Hughes
b877601bff Put struct FILE back how NDK-built apps expect it.
The first rule of stdio is you never change struct FILE. This broke all
NDK-built apps that used stdin/stdout/stderr. (Which is more than you
might think, given that those streams don't go anywhere useful. Svelte!)

I've added a big code comment because I knew when I removed the field that
doing so was a mistake, but I couldn't think why.

Bug: http://b/24807045
Bug: http://b/26747402
Change-Id: Ie1233586b223bb1cdf8e354c66d5ff23487a833a
2016-01-22 19:23:40 -08:00
Dimitry Ivanov
bba395492a Revert "Temporary apply LIBC version to __pthread_gettid"
This reverts commit 0ef1d121b5.

Bug: http://b/26392296
Bug: http://b/26391427
Change-Id: I7bbb555de3a43813e7623ff6ad4e17874d283eca
2016-01-22 01:43:04 +00:00
Dimitry Ivanov
05c2f6b3d3 Merge "libc: hide __signalfd4 symbol" 2016-01-22 01:41:27 +00:00
Dimitry Ivanov
90d2daec51 libc: hide fake_gmtime_r and fake_localtime_r
Bug: http://b/26274444
Change-Id: Icf96a00142a287d8d3466d2545e213e605601b42
2016-01-21 16:05:23 -08:00
Dimitry Ivanov
1a8732c232 libc: hide __signalfd4 symbol
Bug: http://b/26274444
Change-Id: Iaa2df640cac07e2e407ca11b9701ee9e11729146
2016-01-21 15:19:52 -08:00
Elliott Hughes
2704bd1340 Simplify fseek/ftell.
Another step towards _FILE_OFFSET_BITS=64 support.

Bug: http://b/24807045
Change-Id: I00b83c81a7b108176c4d9437bc32611f73b7e967
2016-01-21 10:34:35 -08:00
Elliott Hughes
5f1ff279ea Merge "Move stdio implementation details around a little." 2016-01-20 23:07:50 +00:00
Colin Cross
6dcab28311 Update Android.bp to match Android.mk
Change-Id: Ia14a7af94d6220b3078b8d37b76990454b16703c
2016-01-20 12:01:19 -08:00
Colin Cross
18dea9b8d4 Merge "Update Android.bp to match Android.mk" 2016-01-20 19:58:16 +00:00
Elliott Hughes
021335ebda Move stdio implementation details around a little.
Change-Id: I24594426d5479bdd55cbef0ab1b7d76c249dbd0c
2016-01-20 08:50:51 -08:00
Elliott Hughes
8b49f53a5e Merge "Make FILE*s less usable after fclose(3)." 2016-01-20 00:13:45 +00:00
Elliott Hughes
923f165b29 Make FILE*s less usable after fclose(3).
BSD doesn't invalidate the fd stored in struct FILE, which can make
it possible (via fileno(3), for example), to perform operations on
an fd you didn't intend to (rather than just failing with EBADF).

Fixing this makes the code slightly simpler anyway, and might help
catch bad code before it ships.

Bug: http://stackoverflow.com/questions/10816837/fclose-works-differently-on-android-and-linux
Change-Id: I9db74584038229499197a2695c70b58ed0372a87
2016-01-19 15:46:05 -08:00
Colin Cross
8ce38af73a Update Android.bp to match Android.mk
Change-Id: Ib6ab28c5b4569c9537c4647b3661166fdb82544a
2016-01-19 12:50:20 -08:00
Chih-Hung Hsieh
b43ee658bb Switch libc default to clang.
* Default to clang when USE_CLANG_PLATFORM_BUILD is not set
  and the target has no clang bug.

BUG: 26102335
Change-Id: Ied6c9dc5593bfbadbb8d8b38e66ea237d649bae5
2016-01-19 10:59:34 -08:00
Elliott Hughes
d1293faba6 Fix GCC build breakage.
Change-Id: I0339f525c68af942fb97f4bffc771717e67e0e07
2016-01-19 09:47:47 -08:00
Elliott Hughes
94ddc29c0e Merge "Add more fortify symbols to the expected differences from glibc." 2016-01-19 17:25:01 +00:00
Elliott Hughes
ed57b98758 Implement if_nameindex(3)/if_freenameindex(3).
This is just a subset of the recently-implemented getifaddrs(3), though if
we want to handle interfaces (such as "rmnet_*") that don't have an address,
we need to either expose ifaddrs_storage and keep track of which interfaces
we've already seen (which is pretty messy), or refactor the netlink code so
we can reuse it and just extract the information we need for if_nameindex(3).
This patch goes the latter route.

Also clean up if_nametoindex(3) and if_indextoname(3).

Change-Id: I5ffc5df0bab62286cdda2e7af06f032c767119a8
2016-01-18 12:07:38 -08:00
Elliott Hughes
d07c4434f1 Add more fortify symbols to the expected differences from glibc.
Change-Id: I6266b2e6cbea3c014b4ea30a7100186965e40cf1
2016-01-15 19:54:31 -08:00
Elliott Hughes
68d0150221 Merge "Sync with upstream OpenBSD." 2016-01-16 03:02:06 +00:00
Elliott Hughes
506c6deff7 Sync with upstream OpenBSD.
Also some minor build cleanup.

Change-Id: Ibd20602d7ea45685f0c47fceb00ffd6c7ae35954
2016-01-15 16:30:18 -08:00
Dan Willemsen
9c9aa74970 Align Soong builds closer to Make
This moves the Android.bp file to use wildcards in the same places that
they're using in the Android.mk file. It also fixes a file that was in a
different order.

Make and Soong still produce binaries with object files in different
orders, but that's due to Make reordering the object files based on
compile type. Soong keeps the original specified order. It's not
possible to emulate the reordered files in the Android.bp, since the
arch-specific files won't interleave properly.

Change-Id: I9052b3ed7c523c13df5cbe606f913c32c88c7c5f
2016-01-15 16:06:25 -08:00
Dan Willemsen
e4f486ca25 Fix Soong mips builds
Change-Id: I6ae8208e077d831969b08e7abd232deaa20ceca1
2016-01-13 23:22:22 -08:00
Dan Willemsen
4031cbe9c2 Fix Soong x86 builds
Change-Id: Ida3f3584f832d61caf7200557ea57be799eaf38e
2016-01-13 13:37:01 -08:00
Dimitry Ivanov
126d5ab779 Merge "Revert "Move __system_property* to LIBC_PRIVATE for lp64 libc"" 2016-01-13 20:35:25 +00:00
Dimitry Ivanov
e1078a939a Revert "Move __system_property* to LIBC_PRIVATE for lp64 libc"
This reverts commit ff14fb5a1f.

Bug: http://b/26497521
Change-Id: Id7131b37a31e936db0e72ef9969e1f13d2dd578f
2016-01-13 20:32:12 +00:00
Colin Cross
2487f3e15f Merge "Rearrange build files to support USE_SOONG=true" 2016-01-13 20:32:09 +00:00
Dan Willemsen
5d10e69bea Merge "Fix Soong x86 atom builds" 2016-01-13 20:32:07 +00:00
Colin Cross
c292f57ec7 Merge "Update Android.bp for changes to Android.mk" 2016-01-13 20:31:39 +00:00