diff --git a/tests/Kernel/Containers/list_test.cpp b/tests/Kernel/Containers/list_test.cpp index 3325c579a..470a8634c 100644 --- a/tests/Kernel/Containers/list_test.cpp +++ b/tests/Kernel/Containers/list_test.cpp @@ -140,3 +140,16 @@ TEST_CASE ("contains") { CHECK_EQ (contains (normal, 2L), true); CHECK_EQ (contains (normal, 3L), true); } + +TEST_CASE ("long list under stack size") { + int initial_mem_used= mem_used (); + cout << "Initial mem used: " << initial_mem_used << LF; + list long_l; + // increase the size to 5000, there will be a stackoverflow on Windows + for (int i= 0; i < 4000; i++) { + long_l= list ("88888888", long_l); + } + int final_mem_used= mem_used (); + cout << "Final mem used: " << final_mem_used << LF; + cout << "Actual mem used: " << final_mem_used - initial_mem_used << LF; +} diff --git a/xmake.lua b/xmake.lua index 6b8f01ab3..757f30b49 100644 --- a/xmake.lua +++ b/xmake.lua @@ -187,6 +187,9 @@ function add_test_target(filepath) if is_plat("windows") then add_cxxflags("/utf-8") add_ldflags("/LTCG") + -- https://learn.microsoft.com/en-us/cpp/build/reference/stack-stack-allocations?view=msvc-170 + -- explicitly set stack size to 1M on windows + add_ldflags("/STACK:1048576") end if is_plat("windows") or is_plat("mingw") then