Skip to content

Commit

Permalink
Release resources when repeating dlopen-dlcose.
Browse files Browse the repository at this point in the history
When the libbinder.so is dlopen and dlclose many
times, we need to delete the pthread_key and
munmap the memory mapping.

Otherwise, it will crash as the leakage causes
the pthread_key or memory mapping surpass their
limit.

Change-Id: Ice64d4ef685c1f665350286f9e5ddf790beac236
Signed-off-by: zhongjie <[email protected]>
  • Loading branch information
intelzhongjie authored and task650 committed Jan 24, 2017
1 parent f18ee65 commit b83a605
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions libs/binder/IPCThreadState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ void IPCThreadState::shutdown()
delete st;
pthread_setspecific(gTLS, NULL);
}
pthread_key_delete(gTLS);
gHaveTLS = false;
}
}
Expand Down
7 changes: 7 additions & 0 deletions libs/binder/ProcessState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ ProcessState::ProcessState()

ProcessState::~ProcessState()
{
if (mDriverFD >= 0) {
if (mVMStart != MAP_FAILED) {
munmap(mVMStart, BINDER_VM_SIZE);
}
close(mDriverFD);
}
mDriverFD = -1;
}

}; // namespace android

0 comments on commit b83a605

Please sign in to comment.