summaryrefslogtreecommitdiff
path: root/libs/gui/ConsumerBase.cpp
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2021-10-14 14:00:08 -0700
committer Steven Moreland <smoreland@google.com> 2021-10-14 14:28:16 -0700
commitee9df90157863cf12ca2cce7d00324e0974d6ac1 (patch)
tree7e57d779aaed00a887de24bd7925572ad47038a4 /libs/gui/ConsumerBase.cpp
parentd8b3d5f05695af40955c2d3e1d40c51db437f977 (diff)
libbinder: ProcessState warn on forked
Reasonably common error, when people's programs are crashing, because libbinder does not support forking (and supporting forking is really complicated and error prone in multithreaded processes: pthread_atfork documentation states this The intent of pthread_atfork() was to provide a mechanism whereby the application (or a library) could ensure that mutexes and other process and thread state would be restored to a consistent state. In practice, this task is generally too difficult to be practicable. specifically, in libbinder, we would have to: - get all of the libbinder-related locks - make sure the kernel driver can handle forking (or open a new binder fd by reinstantiating ProcessState) - (actual difficulty here) make sure we can capture and release application-specific locks - in a multithreaded process, anything could be going on So, we don't want to take on the complexity of supporting it). Instead now, we install a pthread_atfork handler which marks the ProcessState as invalid in the child process. If code tries to access ProcessState after forking, then it will throw an error (future: abort). Note: forking and then using non-binder things, such as what installd and vold does, is okay. Bug: 202289725 Test: boot and check logs (none) Change-Id: I18638a3190ed2ea23945413c2e5ab15d7094d0b0
Diffstat (limited to 'libs/gui/ConsumerBase.cpp')
0 files changed, 0 insertions, 0 deletions