This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] strace: Fix crash caused over-optimization


On 15/04/2017 23:27, Daniel Santos wrote:
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));

wouldn't adding volatile to the definition of buf be a better way to write this?

   exit (main2 (argc, argv));
 }




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]