summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c83243b)
raw | patch | inline | side by side (parent: c83243b)
author | Ajay Jayaraj <ajayj@ti.com> | |
Thu, 15 Nov 2018 16:50:37 +0000 (10:50 -0600) | ||
committer | Ajay Jayaraj <ajayj@ti.com> | |
Thu, 15 Nov 2018 16:50:37 +0000 (10:50 -0600) |
Initialize ExecutionObject::current_frame_idx_m array to 0 in the
ExecutionObject constructor to prevent out of range entries when
recording trace data.
In a pipelined processing loop, the application executes
ExecutionObject::ProcessFrameWait() on the first frame before it calls
ExecutionObject::ProcessFrameStartAsync. The side effect is that the
current_frame_idx_m is not initialized. This can result in negative
frame indices when writing trace data using ReportTrace or UpdateTrace
leading to memory errors.
Setting ExecutionObject::current_frame_idx_m to 0 in the constructor
avoids this scenario.
(MCT-1085)
ExecutionObject constructor to prevent out of range entries when
recording trace data.
In a pipelined processing loop, the application executes
ExecutionObject::ProcessFrameWait() on the first frame before it calls
ExecutionObject::ProcessFrameStartAsync. The side effect is that the
current_frame_idx_m is not initialized. This can result in negative
frame indices when writing trace data using ReportTrace or UpdateTrace
leading to memory errors.
Setting ExecutionObject::current_frame_idx_m to 0 in the constructor
avoids this scenario.
(MCT-1085)
tidl_api/Makefile | patch | blob | history | |
tidl_api/src/execution_object.cpp | patch | blob | history | |
tidl_api/src/util.cpp | patch | blob | history |
diff --git a/tidl_api/Makefile b/tidl_api/Makefile
index ea6b9dcf451dc4b972df3e6ae0ae3e52f5e54991..abae078564733d1f36d547f274741a3a8566719c 100644 (file)
--- a/tidl_api/Makefile
+++ b/tidl_api/Makefile
CXXFLAGS += $(BUILD_ID)
PY_INCLUDE = -I$(PYTHON_INCLUDE_DIR) -I$(PYBIND11_INC_DIR)
+# pybind11 recommends setting visibility to hidden to reduce code size and
+# prevent name clashed when multiple shared libraries use pybind11
+$(HOST_OBJ_PYBIND_FILES): CXXFLAGS += -fvisibility=hidden
+
$(DSP_OUTFILE): $(DSP_SRCFILE)
$(MAKE) -C dsp
index 20c423cceadc8adda668c621cf9ab0b879b42c75..285dfde60e7efbac6127fa458cb685c3a6f5f1eb 100644 (file)
EnableOutputBufferTrace();
SetupProcessKernel();
+
+ for (int i = 0; i < tidl::internal::NUM_CONTEXTS; i++)
+ current_frame_idx_m[i] = 0;
}
// Pointer to implementation idiom: https://herbsutter.com/gotw/_100/:
diff --git a/tidl_api/src/util.cpp b/tidl_api/src/util.cpp
index b09533e66596dff9cf30707e76124fef42c747e1..8fac9d0bfec036e232a0e22a1df9c9463b625f17 100644 (file)
--- a/tidl_api/src/util.cpp
+++ b/tidl_api/src/util.cpp
num_entries_m(num_entries), file_m(file)
{
entries_m = new Entry[num_entries_m];
- std::memset(entries_m, 0, sizeof(Entry)*num_entries_m);
+ if (entries_m)
+ std::memset(entries_m, 0, sizeof(Entry)*num_entries_m);
}
void TimeStamp::Update(int frame_idx, EventKind k, int type, int id)
{
+ if (!entries_m)
+ return;
+
int idx = frame_idx % num_entries_m;
entries_m[idx].frame_idx = frame_idx;
entries_m[idx].eo2_id = id;
entries_m[idx].eo2_type = type;
}
-
}
void TimeStamp::Zero(int frame_idx, EventKind k)
{
+ if (!entries_m)
+ return;
+
int idx = frame_idx % num_entries_m;
entries_m[idx].frame_idx = frame_idx;
TimeStamp::~TimeStamp()
{
+ if (!entries_m)
+ return;
+
std::ofstream ofs;
ofs.open(file_m, std::ofstream::out);
}
ofs.close();
-
delete [] entries_m;
}