未验证 提交 feba1318 编写于 作者: W wangchaochaohu 提交者: GitHub

fix the sgement fault error of profiler in seqseq model test=develop (#24952)

上级 0cb03182
......@@ -646,7 +646,6 @@ DeviceTracer *GetDeviceTracer() {
// so when event is not in same thread of PE event, we need add
// father event(PE::run event) for this event
void SetCurAnnotation(Event *event) {
std::string ret;
if (!annotation_stack.empty()) {
event->set_parent(annotation_stack.back());
event->set_name(annotation_stack.back()->name() + "/" + event->name());
......@@ -670,17 +669,16 @@ void SetCurAnnotation(Event *event) {
}
void ClearCurAnnotation() {
if (!main_thread_annotation_stack.empty() &&
main_thread_annotation_stack.back()->name() ==
annotation_stack.back()->name()) {
if (!main_thread_annotation_stack.empty()) {
std::string name = annotation_stack.back()->name();
std::string main_name = main_thread_annotation_stack.back()->name();
int main_name_len = main_name.length();
int name_len = name.length();
int prefix_len = main_name_len - name_len;
if (prefix_len >= 0 && main_name.at(prefix_len) == '/' &&
name == main_name.substr(prefix_len, name_len)) {
if ((prefix_len > 0 && main_name.at(prefix_len - 1) == '/' &&
name == main_name.substr(prefix_len, name_len)) ||
(name == main_name)) {
main_thread_annotation_stack_name.pop_back();
main_thread_annotation_stack.pop_back();
}
......
......@@ -71,8 +71,8 @@ RecordEvent::RecordEvent(const std::string &name, const EventRole role) {
role_ = role;
is_enabled_ = true;
// lock is not needed, the code below is thread-safe
Event *e = PushEvent(name, role);
// Maybe need the same push/pop behavior.
Event *e = PushEvent(name, role);
SetCurAnnotation(e);
name_ = e->name();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册