mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 18:20:04 +00:00
Fix deadlock during application startup
When the main thread obtains a lock and also receives the SIGPROF signal, it interrupts the current program to execute the signal processing function, and then retrieves the lock from the function, causing a deadlock. When it is confirmed that the signal processing operation has been performed, the operation of obtaining the lock will no longer be performed. Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAHVEQ Signed-off-by: daiweihao <daiweihao1@huawei.com> Change-Id: I6cdcc10427af48671cdd50d15bd3e6b06e10bb85
This commit is contained in:
parent
1d5427f892
commit
536c555f79
@ -23,6 +23,7 @@
|
||||
#include "ecmascript/js_tagged_value-inl.h"
|
||||
#include "ecmascript/mem/space.h"
|
||||
#include "ecmascript/object_factory-inl.h"
|
||||
#include "ecmascript/debugger/js_debugger_manager.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
/* static */
|
||||
@ -203,11 +204,32 @@ inline EcmaString *EcmaString::CreateConstantString(const EcmaVM *vm, const uint
|
||||
return string;
|
||||
}
|
||||
|
||||
/*
|
||||
* In the multi-thread optimization scenario, start the application.
|
||||
* 1.The thread executes until CheckThread () acquires the lock.
|
||||
* 2.At this time, the thread receives the SIGPROF signal, interrupts the current program execution,
|
||||
* and enters the signal processing function.
|
||||
* 3.When CreateTreeString()->GetJSThread()->CheckThread() is executed, the lock cannot be obtained
|
||||
* and the system has to wait, causing a deadlock.
|
||||
* Therefore, if the function is executed during signal processing, the thread ID is directly obtained and
|
||||
* the thread detection is not performed, thereby avoiding deadlock.
|
||||
*/
|
||||
|
||||
inline void GetDebuggerThread(const EcmaVM *vm, JSThread **thread)
|
||||
{
|
||||
if (vm->GetJsDebuggerManager()->GetSignalState()) {
|
||||
*thread = vm->GetJSThreadNoCheck();
|
||||
} else {
|
||||
*thread = vm->GetJSThread();
|
||||
}
|
||||
}
|
||||
|
||||
inline EcmaString *EcmaString::CreateTreeString(const EcmaVM *vm,
|
||||
const JSHandle<EcmaString> &left, const JSHandle<EcmaString> &right, uint32_t length, bool compressed)
|
||||
{
|
||||
ECMA_STRING_CHECK_LENGTH_AND_TRHOW(vm, length);
|
||||
auto thread = vm->GetJSThread();
|
||||
JSThread *thread = nullptr;
|
||||
GetDebuggerThread(vm, &thread);
|
||||
auto string = TreeEcmaString::Cast(vm->GetFactory()->AllocTreeStringObject());
|
||||
string->SetLength(length, compressed);
|
||||
string->SetRawHashcode(0);
|
||||
|
Loading…
Reference in New Issue
Block a user