From 3c92cab9688e6767ca31f5a5a4a04a2700003ced Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Thu, 4 May 2023 20:44:33 +0300 Subject: [PATCH] ets: Fix preinitialization StackOverflowError Signed-off-by: Vyacheslav Cherkashin --- plugins/ets/runtime/ets_language_context.h | 2 +- plugins/ets/runtime/ets_vm.cpp | 2 +- plugins/ets/stdlib/std/core/StdExceptions.ets | 9 +++++++++ plugins/ets/tests/integrational/mock_stdlib.pa | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/ets/runtime/ets_language_context.h b/plugins/ets/runtime/ets_language_context.h index 401292019..2909ef6af 100644 --- a/plugins/ets/runtime/ets_language_context.h +++ b/plugins/ets/runtime/ets_language_context.h @@ -100,7 +100,7 @@ public: const uint8_t *GetStackOverflowErrorClassDescriptor() const override { - return utf::CStringAsMutf8("Lstd/core/StackOverflowException;"); + return utf::CStringAsMutf8("Lstd/core/StackOverflowError;"); } const uint8_t *GetArrayIndexOutOfBoundsExceptionClassDescriptor() const override diff --git a/plugins/ets/runtime/ets_vm.cpp b/plugins/ets/runtime/ets_vm.cpp index 2384a717d..18796bb8b 100644 --- a/plugins/ets/runtime/ets_vm.cpp +++ b/plugins/ets/runtime/ets_vm.cpp @@ -214,7 +214,7 @@ bool PandaEtsVM::Initialize() bool PandaEtsVM::InitializeFinish() { - // Preinitialize StackOverflowException, so we don't need to do this when stack overflow occurred + // Preinitialize StackOverflowError, so we don't need to do this when stack overflow occurred auto ctx = ets::utils::GetLanguageContext(); auto boot_context = ets::utils::GetClassLinkerExtension()->GetBootContext(); diff --git a/plugins/ets/stdlib/std/core/StdExceptions.ets b/plugins/ets/stdlib/std/core/StdExceptions.ets index ebe5492ec..a69eb3e02 100644 --- a/plugins/ets/stdlib/std/core/StdExceptions.ets +++ b/plugins/ets/stdlib/std/core/StdExceptions.ets @@ -255,6 +255,15 @@ class NoSuchMethodError extends Exception { } } +/** + * @class Represents exception that is thrown when the available memory is not sufficient to create the activation frame + */ +class StackOverflowError extends Exception { + constructor() { + super(); + } +} + /** * @class Represents exception that is thrown when attempting to store an object of different type in array of type-erased objects */ diff --git a/plugins/ets/tests/integrational/mock_stdlib.pa b/plugins/ets/tests/integrational/mock_stdlib.pa index 44b19a41a..c64f2475c 100644 --- a/plugins/ets/tests/integrational/mock_stdlib.pa +++ b/plugins/ets/tests/integrational/mock_stdlib.pa @@ -15,6 +15,7 @@ .record std.core.String .record std.core.Object +.record std.core.StackOverflowError .record std.core.OutOfMemoryError { std.core.String message -- Gitee