This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[testsuite] Fix gcc.dg/tree-prof/val-profiler-threads-1.c
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 28 Jun 2017 09:51:54 +0200
- Subject: [testsuite] Fix gcc.dg/tree-prof/val-profiler-threads-1.c
- Authentication-results: sourceware.org; auth=none
The manual says that the type of the 2nd argument of pthread_join is void **.
Now gcc.dg/tree-prof/val-profiler-threads-1.c does this:
int retval;
for(t=0;t<NUM_THREADS;t++)
pthread_join (threads[t], (void**)&retval);
which means a potential buffer overflow on LP64 targets in addition to an
alignment issue if the target is strict-alignment, for example SPARC 64-bit.
Tested on SPARC64/Linux, applied on the mainline and 7 branch as obvious.
2017-06-28 Eric Botcazou <ebotcazou@adacore.com>
* gcc.dg/tree-prof/val-profiler-threads-1.c (main): Fix 2nd argument
passed to pthread_join.
--
Eric Botcazou
Index: gcc.dg/tree-prof/val-profiler-threads-1.c
===================================================================
--- gcc.dg/tree-prof/val-profiler-threads-1.c (revision 249619)
+++ gcc.dg/tree-prof/val-profiler-threads-1.c (working copy)
@@ -35,9 +35,9 @@ int main(int argc, char *argv[])
}
}
- int retval;
+ void *retval;
for(t=0;t<NUM_THREADS;t++)
- pthread_join (threads[t], (void**)&retval);
+ pthread_join (threads[t], &retval);
return buffer[10];
}