From: SF/projects/mingw n. l. <min...@li...> - 2011-11-30 13:03:32
|
Patches item #3446009, was opened at 2011-11-30 04:26 Message generated for change (Comment added) made by earnie You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=302435&aid=3446009&group_id=2435 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: runtime Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: rodrigo (rodrigo_rc) >Assigned to: Chris Sutcliffe (ir0nh34d) Summary: Regression of 3105314: mingw crashes with GCC 4.6 Initial Comment: The latest update to file winsup/mingw/tlssup.c has undo the path I sent about a year ago in ID: 3105314, so the same bug reappeared. The difference now is that GCC 4.6 is no longer experimental, so the problem is more notorious. For reference, I copy the description again and an updated patch (this time with comments). The issue here seems to be that the new GCC optimizes away the comparison before the first iteration of the loop, so if the list is empty (which is in simple test programs), it crashes. The patch below solves the issue by avoiding the comparison between pointers to global variables. --- a/tlssup.c 2011-11-30 15:20:26.388725544 +0100 +++ b/tlssup.c 2011-11-30 15:25:26.798214841 +0100 @@ -84,7 +84,7 @@ __dyn_tls_init (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) { _PVFV *pfunc; - + int nfuncs, ifunc; /* We don't let us trick here. */ if (_CRT_MT != 2) _CRT_MT = 2; @@ -96,8 +96,12 @@ return TRUE; } - for (pfunc = &__xd_a + 1; pfunc != &__xd_z; ++pfunc) + /* Use the nfuncs variable to iterate the TLS functions instead of pfunc to avoid + nasty compiler optimizations when comparing two global pointers. */ + nfuncs = &__xd_z - (&__xd_a + 1); + for (ifunc = 0; ifunc < nfuncs; ++ifunc) { + pfunc = (&__xd_a + 1) + ifunc; if (*pfunc != NULL) (*pfunc)(); } Changelog: mingw/ 2011-11-30 Rodrigo Rivas Costa <rod...@gm...> * tlssup.c (__dyn_tls_init): Reapply patch from 3105314. ---------------------------------------------------------------------- >Comment By: Earnie Boyd (earnie) Date: 2011-11-30 05:03 Message: I confirm the patch corrects the issue I was having. ---------------------------------------------------------------------- Comment By: Earnie Boyd (earnie) Date: 2011-11-30 04:49 Message: In the future please upload a patch file. SF screws with the spaces when displaying the entered text. ---------------------------------------------------------------------- Comment By: Chris Sutcliffe (ir0nh34d) Date: 2011-11-30 04:32 Message: Thank you for the heads up and the patch. This likely corrects the issue reported here: http://sourceforge.net/tracker/?func=detail&atid=102435&aid=3443215&group_id=2435 I will test and commit your patch later tonight. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=302435&aid=3446009&group_id=2435 |