Tom Rollet has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/68357?usp=email )
Change subject: cpu-o3: fix false positive in AddressSanitizer
......................................................................
cpu-o3: fix false positive in AddressSanitizer
AddressSanitizer found a new-delete-type-mismatch because of
the custom new operator for DynInst.
Adding a custom delete operator for DynInstPtr fixes this issue.
It has been fixed the same way in Mozilla:
https://bugzilla.mozilla.org/show_bug.cgi?id=1391500
Change-Id: I0ab4cb6d79cac88069cc2374a1deb499cdb15f02
---
M src/cpu/o3/dyn_inst.cc
M src/cpu/o3/dyn_inst.hh
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/src/cpu/o3/dyn_inst.cc b/src/cpu/o3/dyn_inst.cc
index 0b9a900..94433cf 100644
--- a/src/cpu/o3/dyn_inst.cc
+++ b/src/cpu/o3/dyn_inst.cc
@@ -187,6 +187,15 @@
return buf;
}
+// Because of the custom "new" operator that allocates more bytes than the
+// size of the DynInst object, AddressSanitizer throw
new-delete-type-mismatch.
+// Adding a custom delete function is enough to shut down this false
positive
+void
+DynInst::operator delete(void *ptr)
+{
+ ::operator delete(ptr);
+}
+
DynInst::~DynInst()
{
/*
diff --git a/src/cpu/o3/dyn_inst.hh b/src/cpu/o3/dyn_inst.hh
index ab165bb..5feb60a 100644
--- a/src/cpu/o3/dyn_inst.hh
+++ b/src/cpu/o3/dyn_inst.hh
@@ -95,6 +95,7 @@
};
static void *operator new(size_t count, Arrays &arrays);
+ static void operator delete(void*);
/** BaseDynInst constructor given a binary instruction. */
DynInst(const Arrays &arrays, const StaticInstPtr &staticInst,
--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/68357?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I0ab4cb6d79cac88069cc2374a1deb499cdb15f02
Gerrit-Change-Number: 68357
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Rollet <tom.rol...@huawei.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org