[Openmp-commits] [PATCH] D112174: [OpenMP] Fix possible NULL dereference
Andrey Churbanov via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Wed Oct 20 13:00:12 PDT 2021
AndreyChurbanov created this revision.
AndreyChurbanov added reviewers: hbae, jlpeyton, Nawrin, tlwilmar.
AndreyChurbanov added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
AndreyChurbanov requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, sstefan1.
According to dlsym description, the value of symbol could be NULL,
and there is no error in this case. Thus dlerror will also return NULL in
this case. We need to check the value returned by dlerror before printing it.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D112174
Files:
openmp/runtime/src/ompt-general.cpp
Index: openmp/runtime/src/ompt-general.cpp
===================================================================
--- openmp/runtime/src/ompt-general.cpp
+++ openmp/runtime/src/ompt-general.cpp
@@ -346,9 +346,16 @@
OMPT_VERBOSE_INIT_CONTINUED_PRINT("Success. \n");
OMPT_VERBOSE_INIT_PRINT("Searching for ompt_start_tool in %s... ",
fname);
+ dlerror(); // Clear any existing error
start_tool = (ompt_start_tool_t)dlsym(h, "ompt_start_tool");
if (!start_tool) {
- OMPT_VERBOSE_INIT_CONTINUED_PRINT("Failed: %s\n", dlerror());
+ char *error = dlerror();
+ if (error != NULL) {
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT("Failed: %s\n", error);
+ } else {
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT("Failed: %s\n",
+ "ompt_start_tool = NULL");
+ }
} else
#elif KMP_OS_WINDOWS
OMPT_VERBOSE_INIT_PRINT("Opening %s... ", fname);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112174.381075.patch
Type: text/x-patch
Size: 1011 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20211020/5c9137d8/attachment.bin>
More information about the Openmp-commits
mailing list