Skip to content

Commit 633fbf3

Browse files
committed
rcache: Handle posix_memalign failures
Glibc tags posix_memalign to generate a warning if the return value is ignored. In recent systems, this seems completely uncalled for, since addr must not be touched. But older systems did not enforce that behavior, so reset addr and move on. Signed-off-by: Brian Barrett <bbarrett@amazon.com>
1 parent 6fea889 commit 633fbf3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

opal/mca/mpool/base/mpool_base_default.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ static void *mca_mpool_default_alloc(mca_mpool_base_module_t *mpool, size_t size
3434
if (align <= sizeof(void *)) {
3535
addr = malloc(size);
3636
} else {
37-
(void) posix_memalign(&addr, align, size);
37+
int ret = posix_memalign(&addr, align, size);
38+
if (ret < 0) {
39+
/* old systems may not guarantee that addr wasn't modified
40+
on failure */
41+
addr = NULL;
42+
}
3843
}
3944
return addr;
4045
#else

0 commit comments

Comments
 (0)