diff options
author | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-16 00:40:35 +0000 |
---|---|---|
committer | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-16 00:40:35 +0000 |
commit | 7a5506d3176efc746a78b4dbcfe8bfb39da53158 (patch) | |
tree | c3cd843c3561ed2feb1d093aab3332b3bb92a75a /base/threading | |
parent | 6de5838db6e5afe923092cf1de1ca80caf47b5fd (diff) | |
download | chromium_src-7a5506d3176efc746a78b4dbcfe8bfb39da53158.zip chromium_src-7a5506d3176efc746a78b4dbcfe8bfb39da53158.tar.gz chromium_src-7a5506d3176efc746a78b4dbcfe8bfb39da53158.tar.bz2 |
[POSIX] Fix pthread_create check
When pthread_create create fails, the content of handle becomes
undefined, but PlatformThreadHandle::platform_handle is initialized to
0, which makes the CHECK_EQ fail.
Fix by resetting handle to 0 if pthread_create fails.
BUG=373905
Review URL: https://codereview.chromium.org/289013003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270875 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/threading')
-rw-r--r-- | base/threading/platform_thread_posix.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc index 421830e..5b609c1 100644 --- a/base/threading/platform_thread_posix.cc +++ b/base/threading/platform_thread_posix.cc @@ -116,13 +116,15 @@ bool CreateThread(size_t stack_size, bool joinable, params.priority = priority; params.handle = thread_handle; - pthread_t handle = 0; + pthread_t handle; int err = pthread_create(&handle, &attributes, ThreadFunc, ¶ms); success = !err; if (!success) { + // Value of |handle| is undefined if pthread_create fails. + handle = 0; errno = err; PLOG(ERROR) << "pthread_create"; } |