From 41a96af0554b2a51c59765d0754fc0df52b6a243 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Thu, 19 Jun 2025 12:08:10 +0300 Subject: [PATCH] Fix for out of memory for primitive type Signed-off-by: Sergey Ignatov --- .../test.ets | 36 ++++++++++++++++--- .../ets-cts/ets-cts-excluded-JIT-REPEATS.txt | 9 ----- .../ets-cts/ets-cts-ignored-AMD64.txt | 8 ----- .../ets-cts/ets-cts-ignored-ARM64-JIT.txt | 8 ----- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/static_core/plugins/ets/tests/ets-templates/20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test.ets b/static_core/plugins/ets/tests/ets-templates/20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test.ets index 5339bbf706..9be2150bfc 100644 --- a/static_core/plugins/ets/tests/ets-templates/20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test.ets +++ b/static_core/plugins/ets/tests/ets-templates/20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test.ets @@ -20,7 +20,7 @@ desc: >- Execution of some primitive type operations can throw OutOfMemoryError if allocation of new object is required but the available memory is not sufficient to perform it. -ark_options: ['--heap-size-limit=16777216'] +ark_options: ['--heap-size-limit=10485760','--compiler-enable-osr=false','--heap-verifier=fail_on_verification'] timeout: 1800 ---*/ @@ -33,17 +33,45 @@ function append () { array.push(n) // just store the variable in dynamic array } +function fillHeap() { + let holder : FixedArray = new Object[10]; + try { + for (let i = 0; i < holder.length; ++i) { + let res : FixedArray = new Byte[250 * 1024] + holder[i] = res + } + } catch (error: Error) { + console.log("catch error in fillHeap") + throw error + } + return holder +} + function main() { + try { + let holder = fillHeap(); + } catch (error: Error) { + if (error instanceof OutOfMemoryError) { + console.log("OutOfMemoryError when fillHeap") + throw new Error("OutOfMemoryError when fillHeap") + } + console.log("Unknown error when fillHeap") + throw new Error("Unknown error when fillHeap") + } try { for (;;) { // infinite loop append() } } catch (error: Error) { - if (error instanceof OutOfMemoryError) // OK - return + if (error instanceof OutOfMemoryError) { // OK + console.log("Out of memory from main loop count " + count) + throw new Error("Out of memory from main loop count " + count) + // return + } - throw error // Unknown error + console.log("Unknown error from main loop count " + count) // Unknown error + throw new Error("Unknown error from main loop count " + count) // Unknown error } } diff --git a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-excluded-JIT-REPEATS.txt b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-excluded-JIT-REPEATS.txt index c1db1fb9cb..e9a1d27f9b 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-excluded-JIT-REPEATS.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-excluded-JIT-REPEATS.txt @@ -99,12 +99,3 @@ 17.experimental_features/16.async_functions_and_methods/02.async_methods/async_method26.ets 17.experimental_features/16.async_functions_and_methods/02.async_methods/async_method27.ets 17.experimental_features/16.async_functions_and_methods/02.async_methods/async_method28.ets - -#24226 RUNTIME_TIMEOUT - it required more than 600sec -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_0.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_1.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_2.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_3.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_4.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_5.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_6.ets diff --git a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored-AMD64.txt b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored-AMD64.txt index a04315bcef..e69de29bb2 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored-AMD64.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored-AMD64.txt @@ -1,8 +0,0 @@ -#24304 -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_0.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_1.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_2.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_3.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_4.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_5.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_6.ets diff --git a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored-ARM64-JIT.txt b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored-ARM64-JIT.txt index 6ece3d1fee..e69de29bb2 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored-ARM64-JIT.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored-ARM64-JIT.txt @@ -1,8 +0,0 @@ -#24304 ABORT_FAIL -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_0.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_1.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_2.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_3.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_4.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_5.ets -20.implementation_details/06.outofmemoryerror_for_primitive_type_operations/test_6.ets -- Gitee