* [testsuite] Fix gcc.dg/tree-prof/val-profiler-threads-1.c
@ 2017-06-28 7:51 Eric Botcazou
0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2017-06-28 7:51 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 628 bytes --]
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
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 498 bytes --]
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];
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-06-28 7:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-28 7:51 [testsuite] Fix gcc.dg/tree-prof/val-profiler-threads-1.c Eric Botcazou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).