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
This commit is contained in:
Przemysław Czerpak
2015-08-01 13:14:30 +02:00
parent f9dd95c243
commit 7a80a882ab
2 changed files with 20 additions and 3 deletions

View File

@@ -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

View File

@@ -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 )
{