diff options
author | ted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2012-04-25 11:42:52 +0000 |
---|---|---|
committer | ted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2012-04-25 11:42:52 +0000 |
commit | e6e778f635a1611f4d65145ce83255094d5db272 (patch) | |
tree | 1a89160e1d8158719db0a8aa57d3f919d54dce00 /src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc | |
parent | Fix compiler warning from format string (diff) | |
download | breakpad-e6e778f635a1611f4d65145ce83255094d5db272.tar.xz |
Fix race in VerifyStackReadWithMultipleThreads
Patch by Chris Dearman <chris@mips.com>
R=ted at http://breakpad.appspot.com/377002
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@959 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc')
-rw-r--r-- | src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc b/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc index 6e3d5e4b..418e7e67 100644 --- a/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc +++ b/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc @@ -51,7 +51,14 @@ #endif void *thread_function(void *data) { + int pipefd = *static_cast<int *>(data); volatile pid_t thread_id = syscall(__NR_gettid); + // Signal parent that a thread has started. + uint8_t byte = 1; + if (write(pipefd, &byte, sizeof(byte)) != sizeof(byte)) { + perror("ERROR: parent notification failed"); + return NULL; + } register volatile pid_t *thread_id_ptr asm(TID_PTR_REGISTER) = &thread_id; while (true) asm volatile ("" : : "r" (thread_id_ptr)); @@ -75,14 +82,8 @@ int main(int argc, char *argv[]) { pthread_attr_init(&thread_attributes); pthread_attr_setdetachstate(&thread_attributes, PTHREAD_CREATE_DETACHED); for (int i = 1; i < num_threads; i++) { - pthread_create(&threads[i], &thread_attributes, &thread_function, NULL); - } - // Signal parent that this process has started all threads. - uint8_t byte = 1; - if (write(pipefd, &byte, sizeof(byte)) != sizeof(byte)) { - perror("ERROR: parent notification failed"); - return 1; + pthread_create(&threads[i], &thread_attributes, &thread_function, &pipefd); } - thread_function(NULL); + thread_function(&pipefd); return 0; } |