Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
9b5a65b8
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2292
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9b5a65b8
编写于
8月 04, 2020
作者:
C
Chen Weihang
提交者:
GitHub
8月 04, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine init signal handler meg dumper (#25911)
上级
ff717d51
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
9 deletion
+27
-9
paddle/fluid/platform/init.cc
paddle/fluid/platform/init.cc
+5
-6
paddle/fluid/platform/init.h
paddle/fluid/platform/init.h
+22
-3
未找到文件。
paddle/fluid/platform/init.cc
浏览文件 @
9b5a65b8
...
@@ -58,7 +58,6 @@ namespace framework {
...
@@ -58,7 +58,6 @@ namespace framework {
std
::
once_flag
gflags_init_flag
;
std
::
once_flag
gflags_init_flag
;
std
::
once_flag
glog_init_flag
;
std
::
once_flag
glog_init_flag
;
std
::
once_flag
p2p_init_flag
;
std
::
once_flag
p2p_init_flag
;
std
::
once_flag
glog_warning_once_flag
;
bool
InitGflags
(
std
::
vector
<
std
::
string
>
args
)
{
bool
InitGflags
(
std
::
vector
<
std
::
string
>
args
)
{
bool
successed
=
false
;
bool
successed
=
false
;
...
@@ -260,22 +259,22 @@ const char *ParseSignalErrorString(const std::string &str) {
...
@@ -260,22 +259,22 @@ const char *ParseSignalErrorString(const std::string &str) {
}
}
// Handle SIGSEGV, SIGILL, SIGFPE, SIGABRT, SIGBUS, and SIGTERM.
// Handle SIGSEGV, SIGILL, SIGFPE, SIGABRT, SIGBUS, and SIGTERM.
std
::
ostringstream
signal_msg_dumper
;
void
SignalHandle
(
const
char
*
data
,
int
size
)
{
void
SignalHandle
(
const
char
*
data
,
int
size
)
{
try
{
try
{
// NOTE1: The glog FailureSignalHandler dumped messages
// NOTE1: The glog FailureSignalHandler dumped messages
// are deal with line by line
// are deal with line by line
auto
signal_msg_dunmer_ptr
=
SignalMessageDumper
::
Instance
().
Get
();
// NOTE2: we only deal with the time info ane signal info,
// NOTE2: we only deal with the time info ane signal info,
// the stack trace will generated by paddle self
// the stack trace will generated by paddle self
if
(
StartsWith
(
data
,
"*** Aborted at"
))
{
if
(
StartsWith
(
data
,
"*** Aborted at"
))
{
signal_msg_dumpe
r
<<
" [TimeInfo: "
<<
std
::
string
(
data
,
size
-
1
)
*
signal_msg_dunmer_pt
r
<<
" [TimeInfo: "
<<
std
::
string
(
data
,
size
-
1
)
<<
"]
\n
"
;
<<
"]
\n
"
;
}
else
if
(
StartsWith
(
data
,
"***"
))
{
}
else
if
(
StartsWith
(
data
,
"***"
))
{
std
::
string
signal_info
(
data
,
size
-
1
);
std
::
string
signal_info
(
data
,
size
-
1
);
std
::
string
useless_substr
(
"; stack trace:"
);
std
::
string
useless_substr
(
"; stack trace:"
);
size_t
start_pos
=
signal_info
.
rfind
(
useless_substr
);
size_t
start_pos
=
signal_info
.
rfind
(
useless_substr
);
signal_info
.
replace
(
start_pos
,
useless_substr
.
length
(),
""
);
signal_info
.
replace
(
start_pos
,
useless_substr
.
length
(),
""
);
signal_msg_dumpe
r
<<
" [SignalInfo: "
<<
signal_info
<<
"]
\n
"
;
*
signal_msg_dunmer_pt
r
<<
" [SignalInfo: "
<<
signal_info
<<
"]
\n
"
;
// NOTE3: Here does not throw an exception,
// NOTE3: Here does not throw an exception,
// otherwise it will casue "terminate called recursively"
// otherwise it will casue "terminate called recursively"
auto
exp
=
platform
::
EnforceNotMet
(
auto
exp
=
platform
::
EnforceNotMet
(
...
@@ -283,7 +282,7 @@ void SignalHandle(const char *data, int size) {
...
@@ -283,7 +282,7 @@ void SignalHandle(const char *data, int size) {
"A serious error (%s) is detected by the operating system."
,
"A serious error (%s) is detected by the operating system."
,
ParseSignalErrorString
(
signal_info
)),
ParseSignalErrorString
(
signal_info
)),
__FILE__
,
__LINE__
);
__FILE__
,
__LINE__
);
std
::
cout
<<
exp
.
what
()
<<
signal_msg_dumper
.
str
()
<<
std
::
endl
;
std
::
cout
<<
exp
.
what
()
<<
(
*
signal_msg_dunmer_ptr
)
.
str
()
<<
std
::
endl
;
}
}
}
catch
(...)
{
}
catch
(...)
{
// Since the program has already triggered a system error,
// Since the program has already triggered a system error,
...
...
paddle/fluid/platform/init.h
浏览文件 @
9b5a65b8
...
@@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#pragma once
#pragma once
#include <memory>
#include <mutex> // NOLINT
#include <mutex> // NOLINT
#include <string>
#include <string>
#include <vector>
#include <vector>
...
@@ -22,7 +23,7 @@ limitations under the License. */
...
@@ -22,7 +23,7 @@ limitations under the License. */
namespace
paddle
{
namespace
paddle
{
namespace
platform
{
namespace
platform
{
void
ParseCommandLineFlags
(
int
argc
,
char
**
argv
,
bool
remove
);
void
ParseCommandLineFlags
(
int
argc
,
char
**
argv
,
bool
remove
);
}
// namespace platform
}
// namespace platform
}
// namespace paddle
}
// namespace paddle
...
@@ -32,14 +33,32 @@ namespace framework {
...
@@ -32,14 +33,32 @@ namespace framework {
bool
InitGflags
(
std
::
vector
<
std
::
string
>
argv
);
bool
InitGflags
(
std
::
vector
<
std
::
string
>
argv
);
void
InitGLOG
(
const
std
::
string
&
prog_name
);
void
InitGLOG
(
const
std
::
string
&
prog_name
);
void
InitDevices
(
bool
init_p2p
);
void
InitDevices
(
bool
init_p2p
);
void
InitDevices
(
bool
init_p2p
,
const
std
::
vector
<
int
>
devices
);
void
InitDevices
(
bool
init_p2p
,
const
std
::
vector
<
int
>
devices
);
#ifndef _WIN32
#ifndef _WIN32
void
SignalHandle
(
const
char
*
data
,
int
size
);
class
SignalMessageDumper
{
public:
~
SignalMessageDumper
()
{}
SignalMessageDumper
(
const
SignalMessageDumper
&
o
)
=
delete
;
const
SignalMessageDumper
&
operator
=
(
const
SignalMessageDumper
&
o
)
=
delete
;
static
SignalMessageDumper
&
Instance
()
{
static
SignalMessageDumper
instance
;
return
instance
;
}
std
::
shared_ptr
<
std
::
ostringstream
>
Get
()
{
return
dumper_
;
}
private:
SignalMessageDumper
()
:
dumper_
(
new
std
::
ostringstream
())
{}
std
::
shared_ptr
<
std
::
ostringstream
>
dumper_
;
};
void
SignalHandle
(
const
char
*
data
,
int
size
);
#endif
#endif
}
// namespace framework
}
// namespace framework
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录