34e89c232d
After applying the kernel_id fix, the system refused to boot up and we got following crash log: I/DEBUG ( 113): pid: 618, tid: 618 >>> org.simalliance.openmobileapi.service:remote <<< I/DEBUG ( 113): signal 16 (SIGSTKFLT), code -6 (?), fault addr -------- I/DEBUG ( 113): eax fffffe00 ebx b77de994 ecx 00000080 edx 00724002 I/DEBUG ( 113): esi 00000000 edi 00004000 I/DEBUG ( 113): xcs 00000073 xds 0000007b xes 0000007b xfs 00000000 xss 0000007b I/DEBUG ( 113): eip b7761351 ebp bfdf3de8 esp bfdf3dc4 flags 00000202 I/DEBUG ( 113): #00 eip: 00015351 /system/lib/libc.so I/DEBUG ( 113): #01 eip: 0000d13c /system/lib/libc.so (pthread_mutex_lock) I/DEBUG ( 113): #02 eip: 00077b48 /system/lib/libc.so (__bionic_atfork_run_prepare) I/DEBUG ( 113): #03 eip: 00052cdb /system/lib/libc.so (fork) I/DEBUG ( 113): #04 eip: 0009ae91 /system/lib/libdvm.so (_Z18dvmOptimizeDexFileillPKcjjb) I/DEBUG ( 113): #05 eip: 000819d6 /system/lib/libdvm.so (_Z14dvmJarFileOpenPKcS0_PP7JarFileb) I/DEBUG ( 113): #06 eip: 000b175e /system/lib/libdvm.so (_ZL40Dalvik_dalvik_system_DexFile_openDexFilePKjP6JValue) I/DEBUG ( 113): #07 eip: 0011fb94 /system/lib/libdvm.so Root cause: The atfork uses the mutex handler_mutex to protect the atfork_head. The parent will call __bionic_atfork_run_prepare() to lock the handler_mutex, and need both the parent and child to unlock their own copy of handler_mutex after fork. At that time, the owner of hanlder_mutex is set as the parent. If we apply the kernel_id fix, then the child's kernel_id will be set as child's tid. The handler_mutex is a recursive lock, and pthread_mutex_unlock(&hander_mutex) will fail because the mutex owner is the parent, while the current tid (__get_thread()->kernel_id) is child, not matched with the mutex owner. At that time, the handler_mutex is left in lock state.If the child wants to fork other process after than, then it will try to lock handler_mutex, and then be deadlocked. Fix: Since the child has its own copy of vm space from the the parent, the child space's handler_mutex should be reset to the initialized state. Change-Id: I3907dd9a153418fb78862f2aa6d0302c375d9e27 Signed-off-by: Jack Ren <jack.ren@intel.com> Signed-off-by: Chenyang Du <chenyang.du@intel.com> Signed-off-by: Bruce Beare <bruce.j.beare@intel.com> |
||
---|---|---|
.. | ||
arch-arm | ||
arch-x86 | ||
bionic | ||
docs | ||
include | ||
inet | ||
kernel | ||
netbsd | ||
private | ||
regex | ||
stdio | ||
stdlib | ||
string | ||
tools | ||
tzcode | ||
unistd | ||
wchar | ||
zoneinfo | ||
Android.mk | ||
CAVEATS | ||
Jamfile | ||
MODULE_LICENSE_BSD | ||
NOTICE | ||
README | ||
SYSCALLS.TXT |
Welcome to Bionic, Android's small and custom C library for the Android platform. Bionic is mainly a port of the BSD C library to our Linux kernel with the following additions/changes: - no support for locales - no support for wide chars (i.e. multi-byte characters) - its own smallish implementation of pthreads based on Linux futexes - support for x86, ARM and ARM thumb CPU instruction sets and kernel interfaces Bionic is released under the standard 3-clause BSD License Bionic doesn't want to implement all features of a traditional C library, we only add features to it as we need them, and we try to keep things as simple and small as possible. Our goal is not to support scaling to thousands of concurrent threads on multi-processors machines; we're running this on cell-phones, damnit !! Note that Bionic doesn't provide a libthread_db or a libm implementation. Adding new syscalls: ==================== Bionic provides the gensyscalls.py Python script to automatically generate syscall stubs from the list defined in the file SYSCALLS.TXT. You can thus add a new syscall by doing the following: - edit SYSCALLS.TXT - add a new line describing your syscall, it should look like: return_type syscall_name(parameters) syscall_number - in the event where you want to differentiate the syscall function from its entry name, use the alternate: return_type funcname:syscall_name(parameters) syscall_number - additionally, if the syscall number is different between ARM and x86, use: return_type funcname[:syscall_name](parameters) arm_number,x86_number - a syscall number can be -1 to indicate that the syscall is not implemented on a given platform, for example: void __set_tls(void*) arm_number,-1 the comments in SYSCALLS.TXT contain more information about the line format You can also use the 'checksyscalls.py' script to check that all the syscall numbers you entered are correct. It does so by looking at the values defined in your Linux kernel headers. The script indicates where the values are incorrect and what is expected instead.