Skip to content

Commit f9a451a

Browse files
authored
Reduce memory size used in test_memorygrowth_linear_step. NFC (#23301)
This doesn't change the test other than to use lower memory limits. This change works around #22360 which seems to be some kind of bug in node or v8. The result of the bug is that the node process becomes hung in `uv_cond_wait` and never exists at the end of the test. Changing the amount of memory used seems to work around the issue.
1 parent f604a15 commit f9a451a

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

test/core/test_memorygrowth_linear_step.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,20 @@ int get_memory_size() {
1717
}
1818

1919
int main() {
20-
21-
// INITIAL_MEMORY=64Mb
2220
// STACK_SIZE=1Mb
23-
// MAXIMUM_MEMORY=130Mb
21+
// INITIAL_MEMORY=32Mb
22+
// MAXIMUM_MEMORY=64Mb
2423
// MEMORY_GROWTH_LINEAR_STEP=1Mb
2524

2625
// Because the stack is 1Mb, the first increase will take place
27-
// in i = 63, which attempts to grow the heap to 64Mb + 1Mb of stack > 64Mb INITIAL_MEMORY
28-
// We should get exactly to 130MB at i == 128
26+
// when i = 30, which attempts to grow the memory to 32Mb + 1Mb of stack > 32Mb
27+
// We should get to exactly 64MB at i == 62
2928

3029
const int MB = 1024 * 1024;
31-
const int totalMemory = get_memory_size();
30+
const int initialMemory = get_memory_size();
3231
int printedOnce = 0;
3332

3433
for (int i = 0; 1; i++) {
35-
3634
printf("%d %d %d\n", i, get_memory_size(), get_memory_size() / MB);
3735
volatile long sink = (long)malloc(MB);
3836

@@ -41,16 +39,17 @@ int main() {
4139
// i == 63 > growth to 65MB failed
4240
// i == 128 > growth to 130MB failed
4341
// i == 129 > growth to 131MB failed
44-
assert(i >= 128);
42+
assert(i == 62);
4543
break;
4644
}
4745

48-
if (get_memory_size() > totalMemory && !printedOnce) {
46+
if (get_memory_size() > initialMemory && !printedOnce) {
4947
printf("memory growth started at %d %d %d\n", i, get_memory_size(), get_memory_size() / MB);
5048
printedOnce = 1;
49+
assert(i == 30);
5150
}
5251

53-
assert(i < 130); // the wasm mem max limit, we must not get there
52+
assert(i < 64); // the wasm mem max limit, we must not get there
5453
}
5554

5655
printf("grew memory ok.\n");

test/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2054,7 +2054,7 @@ def test_memorygrowth_linear_step(self):
20542054
self.skipTest('wasm memory specific test')
20552055

20562056
# check that memory growth does not exceed the wasm mem max limit and is exactly or one step below the wasm mem max
2057-
self.emcc_args += ['-sALLOW_MEMORY_GROWTH', '-sSTACK_SIZE=1Mb', '-sINITIAL_MEMORY=64Mb', '-sMAXIMUM_MEMORY=130Mb', '-sMEMORY_GROWTH_LINEAR_STEP=1Mb']
2057+
self.emcc_args += ['-sALLOW_MEMORY_GROWTH', '-sSTACK_SIZE=1Mb', '-sINITIAL_MEMORY=32Mb', '-sMAXIMUM_MEMORY=64Mb', '-sMEMORY_GROWTH_LINEAR_STEP=1Mb']
20582058
self.do_core_test('test_memorygrowth_linear_step.c')
20592059

20602060
@no_ubsan('UBSan seems to effect the precise memory usage')

0 commit comments

Comments
 (0)