[PATCH] strace: Fix crash caused over-optimization
Daniel Santos
daniel.santos@pobox.com
Sat Apr 15 22:23:00 GMT 2017
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
More information about the Cygwin-patches
mailing list