This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
[PATCH] strace: Fix crash caused over-optimization
- From: Daniel Santos <daniel dot santos at pobox dot com>
- To: cygwin-patches at cygwin dot com
- Cc: Daniel Santos <daniel dot santos at pobox dot com>
- Date: Sat, 15 Apr 2017 17:27:50 -0500
- Subject: [PATCH] strace: Fix crash caused over-optimization
- Authentication-results: sourceware.org; auth=none
Recent versions of gcc are optimizing away the TLS buffer allocated in
main, so we need to tell gcc that it's really used.
---
winsup/utils/strace.cc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/winsup/utils/strace.cc b/winsup/utils/strace.cc
index beab67b90..1e581b4a4 100644
--- a/winsup/utils/strace.cc
+++ b/winsup/utils/strace.cc
@@ -1192,6 +1192,8 @@ main (int argc, char **argv)
char buf[CYGTLS_PADSIZE];
memset (buf, 0, sizeof (buf));
+ /* Prevent buf from being optimized away. */
+ __asm__ __volatile__("" :: "m" (buf));
exit (main2 (argc, argv));
}
--
2.11.0