diff --git a/ChangeLog.txt b/ChangeLog.txt index 8a4e7712bf..fe81270daf 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,18 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2015-08-01 13:14 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * src/vm/asort.c + * restored original loop and added different workaround which for + the problem in 64 bit MinGW we exploited. It's dummy function call + inside a loop so probably link time optimization (LTO is enabled + by -O4 in the newest GCC versions) ignore it and the problem will + reappear. Anyhow it only temporary solution which should give time + to create self contain example and report the problem to MinGW + authors - it's highly possible that also other code exploited this + problem so be careful with MinGW64. + % fixed index range checking to eliminate unnecessary index verification + 2015-08-01 01:28 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/vm/asort.c * added workaround for bug in 64 bit MinGW builds diff --git a/src/vm/asort.c b/src/vm/asort.c index 00e4266941..2f7bd0db6a 100644 --- a/src/vm/asort.c +++ b/src/vm/asort.c @@ -280,9 +280,14 @@ static void hb_arraySortStart( PHB_BASEARRAY pBaseArray, PHB_ITEM pBlock, HB_SIZE * pBuffer, * pDest, * pPos, nPos, nTo; pBuffer = ( HB_SIZE * ) hb_xgrab( sizeof( HB_SIZE ) * 2 * nCount ); - nPos = nCount; - while( nPos-- ) + for( nPos = 0; nPos < nCount; ++nPos ) + { +#ifdef __MINGW64__ + /* added dummy function call to disable buggy optimization in MinGW64 */ + hb_gcDummyMark( NULL ); +#endif pBuffer[ nPos ] = nStart + nPos; + } if( hb_arraySortDO( pBaseArray, pBlock, pBuffer, &pBuffer[ nCount ], nCount ) ) pPos = ( pDest = pBuffer ) + nCount; @@ -290,7 +295,7 @@ static void hb_arraySortStart( PHB_BASEARRAY pBaseArray, PHB_ITEM pBlock, pDest = ( pPos = pBuffer ) + nCount; /* protection against array resizing by user codeblock */ - if( nStart + nCount >= pBaseArray->nLen ) + if( nStart + nCount > pBaseArray->nLen ) { if( pBaseArray->nLen > nStart ) {