[Openmp-commits] [PATCH] D21529: Bugfix for segfault in stubs library

Terry Wilmarth via Openmp-commits openmp-commits at lists.llvm.org
Mon Jun 20 12:36:45 PDT 2016


tlwilmar created this revision.
tlwilmar added reviewers: jlpeyton, hbae.
tlwilmar added a subscriber: openmp-commits.
tlwilmar set the repository for this revision to rL LLVM.

There was a segfault in the stubs library in posix_memalign because
of a bad parameter. The fix is to send address of the pointer as a
parameter. Also added check of result of posix_memalign.

Patch by Andrey Churbanov.

Repository:
  rL LLVM

http://reviews.llvm.org/D21529

Files:
  runtime/src/kmp_stub.c

Index: runtime/src/kmp_stub.c
===================================================================
--- runtime/src/kmp_stub.c
+++ runtime/src/kmp_stub.c
@@ -111,9 +111,13 @@
     errno = ENOSYS; // not supported
     return NULL;    // no standard aligned allocator on Windows (pre - C11)
 #else
-    void **res;
-    errno = posix_memalign( res, a, sz );
-    return *res;
+    void *res;
+    int err;
+    if( err = posix_memalign( &res, a, sz ) ) {
+        errno = err; // can be EINVAL or ENOMEM
+        return NULL;
+    }
+    return res;
 #endif
 }
 void * kmp_calloc( size_t nelem, size_t elsize ) { i; return calloc( nelem, elsize ); }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21529.61289.patch
Type: text/x-patch
Size: 647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20160620/d1c10202/attachment.bin>


More information about the Openmp-commits mailing list