!1433 foundation长稳崩溃修复

Merge pull request !1433 from yangliang36/cherry-pick-1653298372
This commit is contained in:
openharmony_ci
2022-05-23 17:06:42 +00:00
committed by Gitee
+20
View File
@@ -35,6 +35,8 @@ DEFINE_HILOG_LABEL("EventRunner");
namespace OHOS {
namespace AppExecFwk {
namespace {
constexpr uint32_t CUSTOM_STACK_SIZE = 512 * 1024;
// Invoke system call to set name of current thread.
inline void SystemCallSetThreadName(const std::string &name)
{
@@ -285,6 +287,24 @@ public:
// Call system call to modify thread name.
SystemCallSetThreadName(inner->threadName_);
size_t stacksize = 0;
pthread_attr_t thread_attr;
int ret = pthread_attr_init(&thread_attr);
if (ret != 0) {
HILOGE("ThreadMain: pthread_attr_init failed.");
}
ret = pthread_attr_getstacksize(&thread_attr, &stacksize);
if (ret != 0) {
HILOGE("ThreadMain: pthread_attr_getstacksize failed.");
}
HILOGE("ThreadMain: stacksize is %{public}zu.", stacksize);
stacksize = CUSTOM_STACK_SIZE;
ret = pthread_attr_setstacksize(&thread_attr, stacksize);
if (ret != 0) {
HILOGE("ThreadMain: pthread_attr_setstacksize failed.");
}
// Enter event loop.
inner->Run();