[Openmp-commits] [PATCH] D116716: [OpenMP][Offloading] Fixed a crash caused by dereferencing nullptr
Shilei Tian via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Wed Jan 5 17:42:05 PST 2022
tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, ronlieb.
Herald added subscribers: guansong, yaxunl.
tianshilei1992 requested review of this revision.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.
In function `DeviceTy::getTargetPointer`, `Entry` could be `nullptr` because of
zero length array section. We need to check if it is a valid iterator before
using it.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D116716
Files:
openmp/libomptarget/src/device.cpp
Index: openmp/libomptarget/src/device.cpp
===================================================================
--- openmp/libomptarget/src/device.cpp
+++ openmp/libomptarget/src/device.cpp
@@ -305,7 +305,9 @@
DataMapMtx.unlock();
// If not a host pointer and no present modifier, we need to wait for the
// event if it exists.
- if (!IsHostPtr && !HasPresentModifier) {
+ // Note: Entry might be nullptr because of zero length array section.
+ if (Entry != HostDataToTargetListTy::iterator() && !IsHostPtr &&
+ !HasPresentModifier) {
Entry->lock();
void *Event = Entry->getEvent();
if (Event) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116716.397757.patch
Type: text/x-patch
Size: 646 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220106/464dd7ee/attachment.bin>
More information about the Openmp-commits
mailing list