Skip to content

Commit 8f0a1a3

Browse files
authored
Merge pull request #5303 from martin-frbg/issue5289
Exit if memory allocation keeps failing, instead of retrying forever
2 parents 2c0dd24 + 162591a commit 8f0a1a3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

driver/others/memory.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2922,6 +2922,7 @@ void *blas_memory_alloc(int procpos){
29222922
blas_unlock(&memory[position].lock);
29232923
#endif
29242924
if (!memory[position].addr) {
2925+
int failcount = 0;
29252926
do {
29262927
#ifdef DEBUG
29272928
printf("Allocation Start : %lx\n", base_address);
@@ -2973,8 +2974,16 @@ void *blas_memory_alloc(int procpos){
29732974
#ifdef DEBUG
29742975
printf(" Success -> %08lx\n", map_address);
29752976
#endif
2976-
if (((BLASLONG) map_address) == -1) base_address = 0UL;
2977-
2977+
if (((BLASLONG) map_address) == -1) {
2978+
base_address = 0UL;
2979+
failcount++;
2980+
if (failcount >10) {
2981+
fprintf(stderr, "OpenBLAS error: Memory allocation still failed after 10 retries, giving up.\n");
2982+
exit(1);
2983+
}
2984+
} else {
2985+
failcount = 0;
2986+
}
29782987
if (base_address) base_address += BUFFER_SIZE + FIXED_PAGESIZE;
29792988

29802989
} while ((BLASLONG)map_address == -1);

0 commit comments

Comments
 (0)