Mageia Bugzilla – Attachment 11684 Details for
Bug 25232
memtest86+ on mga7 isos reboots after starting test (on some hardware) - gcc problem probably
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
Patch to fix test hangs/reboots when built with GCC 8 (based on v5.01)
0001-Fix-test-hangs-when-built-with-recent-versions-of-GC.patch (text/plain), 7.02 KB, created by
Martin Whitaker
on 2020-06-08 16:24:07 CEST
(
hide
)
Description:
Patch to fix test hangs/reboots when built with GCC 8 (based on v5.01)
Filename:
MIME Type:
Creator:
Martin Whitaker
Created:
2020-06-08 16:24:07 CEST
Size:
7.02 KB
patch
obsolete
>From f00284fbd231710125c0b3cc422af7b71e8836a6 Mon Sep 17 00:00:00 2001 >From: Martin Whitaker <mageia@martin-whitaker.me.uk> >Date: Sun, 29 Mar 2020 18:13:34 +0100 >Subject: [PATCH 1/1] Fix test hangs when built with recent versions of GCC. > >Even with -O0, recent versions of GCC (at least v8, maybe earlier) >optimise away the pointer overflow and underflow checks in the tests. >Fix this by rewriting the checks to not rely on undefined behaviour >(pointer arithmetic wrapping). > >diff --git a/test.c b/test.c >index 6665618..2f069be 100644 >--- a/test.c >+++ b/test.c >@@ -195,7 +195,7 @@ void addr_tst2(int me) > BAILR > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; >@@ -240,7 +240,7 @@ void addr_tst2(int me) > BAILR > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; >@@ -328,7 +328,7 @@ void movinvr(int me) > BAILR > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; >@@ -382,7 +382,7 @@ void movinvr(int me) > BAILR > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; >@@ -514,7 +514,7 @@ void movinv1 (int iter, ulong p1, ulong p2, int me) > BAILR > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; >@@ -558,7 +558,7 @@ void movinv1 (int iter, ulong p1, ulong p2, int me) > BAILR > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; >@@ -626,7 +626,7 @@ void movinv1 (int iter, ulong p1, ulong p2, int me) > BAILR > > /* Check for underflow */ >- if (pe - SPINSZ < pe && pe != 0) { >+ if ((pe - start) > SPINSZ && pe != 0) { > pe -= SPINSZ; > } else { > pe = start; >@@ -713,7 +713,7 @@ void movinv32(int iter, ulong p1, ulong lb, ulong hb, int sval, int off,int me) > BAILR > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; >@@ -782,7 +782,7 @@ void movinv32(int iter, ulong p1, ulong lb, ulong hb, int sval, int off,int me) > BAILR > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; >@@ -888,7 +888,7 @@ void movinv32(int iter, ulong p1, ulong lb, ulong hb, int sval, int off,int me) > BAILR > > /* Check for underflow */ >- if (pe - SPINSZ < pe && pe != 0) { >+ if ((pe - start) > SPINSZ && pe != 0) { > pe -= SPINSZ; > } else { > pe = start; >@@ -1009,7 +1009,7 @@ void modtst(int offset, int iter, ulong p1, ulong p2, int me) > BAILR > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; >@@ -1054,7 +1054,7 @@ void modtst(int offset, int iter, ulong p1, ulong p2, int me) > BAILR > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; >@@ -1115,7 +1115,7 @@ void modtst(int offset, int iter, ulong p1, ulong p2, int me) > BAILR > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; >@@ -1186,9 +1186,6 @@ void block_move(int iter, int me) > for (j=0; j<segs; j++) { > calculate_chunk(&start, &end, me, j, 64); > >- // end is always xxxxxffc, so increment so that length calculations are correct >- end = end + 1; >- > pe = start; > p = start; > >@@ -1198,20 +1195,25 @@ void block_move(int iter, int me) > BAILR > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; > } >- if ((pe >= end && end != 0) || (pe < p && end == 0)) { >+ if (pe >= end) { > pe = end; > done++; > } > if (p == pe ) { > break; > } >- len = ((ulong)pe - (ulong)p) / 64; >- //len++; >+ len = (ulong)pe - (ulong)p; >+ if (pe == end) { >+ // On the final step, pe points to the last word, not the start >+ // of the next step, so correct the length. >+ len += 4; >+ } >+ len /= 64; > asm __volatile__ ( > "jmp L100\n\t" > >@@ -1267,8 +1269,6 @@ void block_move(int iter, int me) > for (j=0; j<segs; j++) { > calculate_chunk(&start, &end, me, j, 64); > >- // end is always xxxxxffc, so increment so that length calculations are correct >- end = end + 1; > pe = start; > p = start; > done = 0; >@@ -1276,20 +1276,26 @@ void block_move(int iter, int me) > do { > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; > } >- if ((pe >= end && end != 0) || (pe < p && end == 0)) { >+ if (pe >= end) { > pe = end; > done++; > } > if (p == pe ) { > break; > } >- pp = (ulong)p + (((ulong)pe - (ulong)p) / 2); // Mid-point of this block >- len = ((ulong)pe - (ulong)p) / 8; // Half the size of this block in DWORDS >+ len = (ulong)pe - (ulong)p; >+ if (pe == end) { >+ // On the final step, pe points to the last word, not the start >+ // of the next step, so correct the length. >+ len += 4; >+ } >+ pp = (ulong)p + len/2; // Mid-point of this block >+ len /= 8; // Half the size of this block in DWORDS > for(i=0; i<iter; i++) { > do_tick(me); > BAILR >@@ -1345,8 +1351,6 @@ void block_move(int iter, int me) > for (j=0; j<segs; j++) { > calculate_chunk(&start, &end, me, j, 64); > >- // end is always xxxxxffc, so increment so that length calculations are correct >- end = end + 1; > pe = start; > p = start; > done = 0; >@@ -1355,12 +1359,12 @@ void block_move(int iter, int me) > BAILR > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; > } >- if ((pe >= end && end != 0) || (pe < p && end == 0)) { >+ if (pe >= end) { > pe = end; > done++; > } >@@ -1433,7 +1437,7 @@ void bit_fade_fill(ulong p1, int me) > BAILR > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; >@@ -1475,7 +1479,7 @@ void bit_fade_chk(ulong p1, int me) > BAILR > > /* Check for overflow */ >- if (pe + SPINSZ > pe && pe != 0) { >+ if ((end - pe) > SPINSZ && pe != 0) { > pe += SPINSZ; > } else { > pe = end; >-- >2.21.3
From f00284fbd231710125c0b3cc422af7b71e8836a6 Mon Sep 17 00:00:00 2001 From: Martin Whitaker <mageia@martin-whitaker.me.uk> Date: Sun, 29 Mar 2020 18:13:34 +0100 Subject: [PATCH 1/1] Fix test hangs when built with recent versions of GCC. Even with -O0, recent versions of GCC (at least v8, maybe earlier) optimise away the pointer overflow and underflow checks in the tests. Fix this by rewriting the checks to not rely on undefined behaviour (pointer arithmetic wrapping). diff --git a/test.c b/test.c index 6665618..2f069be 100644 --- a/test.c +++ b/test.c @@ -195,7 +195,7 @@ void addr_tst2(int me) BAILR /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; @@ -240,7 +240,7 @@ void addr_tst2(int me) BAILR /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; @@ -328,7 +328,7 @@ void movinvr(int me) BAILR /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; @@ -382,7 +382,7 @@ void movinvr(int me) BAILR /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; @@ -514,7 +514,7 @@ void movinv1 (int iter, ulong p1, ulong p2, int me) BAILR /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; @@ -558,7 +558,7 @@ void movinv1 (int iter, ulong p1, ulong p2, int me) BAILR /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; @@ -626,7 +626,7 @@ void movinv1 (int iter, ulong p1, ulong p2, int me) BAILR /* Check for underflow */ - if (pe - SPINSZ < pe && pe != 0) { + if ((pe - start) > SPINSZ && pe != 0) { pe -= SPINSZ; } else { pe = start; @@ -713,7 +713,7 @@ void movinv32(int iter, ulong p1, ulong lb, ulong hb, int sval, int off,int me) BAILR /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; @@ -782,7 +782,7 @@ void movinv32(int iter, ulong p1, ulong lb, ulong hb, int sval, int off,int me) BAILR /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; @@ -888,7 +888,7 @@ void movinv32(int iter, ulong p1, ulong lb, ulong hb, int sval, int off,int me) BAILR /* Check for underflow */ - if (pe - SPINSZ < pe && pe != 0) { + if ((pe - start) > SPINSZ && pe != 0) { pe -= SPINSZ; } else { pe = start; @@ -1009,7 +1009,7 @@ void modtst(int offset, int iter, ulong p1, ulong p2, int me) BAILR /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; @@ -1054,7 +1054,7 @@ void modtst(int offset, int iter, ulong p1, ulong p2, int me) BAILR /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; @@ -1115,7 +1115,7 @@ void modtst(int offset, int iter, ulong p1, ulong p2, int me) BAILR /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; @@ -1186,9 +1186,6 @@ void block_move(int iter, int me) for (j=0; j<segs; j++) { calculate_chunk(&start, &end, me, j, 64); - // end is always xxxxxffc, so increment so that length calculations are correct - end = end + 1; - pe = start; p = start; @@ -1198,20 +1195,25 @@ void block_move(int iter, int me) BAILR /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; } - if ((pe >= end && end != 0) || (pe < p && end == 0)) { + if (pe >= end) { pe = end; done++; } if (p == pe ) { break; } - len = ((ulong)pe - (ulong)p) / 64; - //len++; + len = (ulong)pe - (ulong)p; + if (pe == end) { + // On the final step, pe points to the last word, not the start + // of the next step, so correct the length. + len += 4; + } + len /= 64; asm __volatile__ ( "jmp L100\n\t" @@ -1267,8 +1269,6 @@ void block_move(int iter, int me) for (j=0; j<segs; j++) { calculate_chunk(&start, &end, me, j, 64); - // end is always xxxxxffc, so increment so that length calculations are correct - end = end + 1; pe = start; p = start; done = 0; @@ -1276,20 +1276,26 @@ void block_move(int iter, int me) do { /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; } - if ((pe >= end && end != 0) || (pe < p && end == 0)) { + if (pe >= end) { pe = end; done++; } if (p == pe ) { break; } - pp = (ulong)p + (((ulong)pe - (ulong)p) / 2); // Mid-point of this block - len = ((ulong)pe - (ulong)p) / 8; // Half the size of this block in DWORDS + len = (ulong)pe - (ulong)p; + if (pe == end) { + // On the final step, pe points to the last word, not the start + // of the next step, so correct the length. + len += 4; + } + pp = (ulong)p + len/2; // Mid-point of this block + len /= 8; // Half the size of this block in DWORDS for(i=0; i<iter; i++) { do_tick(me); BAILR @@ -1345,8 +1351,6 @@ void block_move(int iter, int me) for (j=0; j<segs; j++) { calculate_chunk(&start, &end, me, j, 64); - // end is always xxxxxffc, so increment so that length calculations are correct - end = end + 1; pe = start; p = start; done = 0; @@ -1355,12 +1359,12 @@ void block_move(int iter, int me) BAILR /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; } - if ((pe >= end && end != 0) || (pe < p && end == 0)) { + if (pe >= end) { pe = end; done++; } @@ -1433,7 +1437,7 @@ void bit_fade_fill(ulong p1, int me) BAILR /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; @@ -1475,7 +1479,7 @@ void bit_fade_chk(ulong p1, int me) BAILR /* Check for overflow */ - if (pe + SPINSZ > pe && pe != 0) { + if ((end - pe) > SPINSZ && pe != 0) { pe += SPINSZ; } else { pe = end; -- 2.21.3
View Attachment As Raw
Actions:
View
Attachments on
bug 25232
: 11684