Skip to content

Commit 8922355

Browse files
authored
[Asyncify] Hint at the stack size possibly being the issue when hitting "unreachable" (#18085)
Helps #17567 Also move the test from the browser suite to other. It's easier to test there and it's faster.
1 parent 77362a4 commit 8922355

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

src/preamble.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,10 @@ function abort(what) {
482482

483483
#if ASSERTIONS == 0
484484
what += '. Build with -sASSERTIONS for more info.';
485+
#elif ASYNCIFY == 1
486+
if (what.indexOf('RuntimeError: unreachable') >= 0) {
487+
what += '. "unreachable" may be due to ASYNCIFY_STACK_SIZE not being large enough (try increasing it)';
488+
}
485489
#endif // ASSERTIONS
486490

487491
// Use a wasm runtime error, because a JS error might be seen as a foreign

test/browser/async_stack_overflow.cpp renamed to test/other/test_asyncify_stack_overflow.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,5 @@ int main(int argc, char* argv[]) {
1717
// We should not get here - the unwind will fail as the stack is too small
1818
printf("We should not get here %d %d %d\n", x, y, z);
1919

20-
REPORT_RESULT(1);
21-
2220
return 0;
2321
}

test/test_browser.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3366,9 +3366,6 @@ def test_async_returnvalue(self, args):
33663366
create_file('filey.txt', 'sync_tunnel\nsync_tunnel_bool\n')
33673367
self.btest('browser/async_returnvalue.cpp', '0', args=['-sASYNCIFY', '-sASYNCIFY_IGNORE_INDIRECT', '--js-library', test_file('browser/async_returnvalue.js')] + args + ['-sASSERTIONS'])
33683368

3369-
def test_async_stack_overflow(self):
3370-
self.btest('browser/async_stack_overflow.cpp', 'abort:RuntimeError: unreachable', args=['-sASYNCIFY', '-sASYNCIFY_STACK_SIZE=4'])
3371-
33723369
def test_async_bad_list(self):
33733370
self.btest('browser/async_bad_list.cpp', '0', args=['-sASYNCIFY', '-sASYNCIFY_ONLY=[waka]', '--profiling'])
33743371

test/test_other.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9182,6 +9182,24 @@ def test_asyncify_advise(self):
91829182
self.assertContained('[asyncify] g can', out)
91839183
self.assertContained('[asyncify] i can', out)
91849184

9185+
def test_asyncify_stack_overflow(self):
9186+
self.emcc_args = ['-sASYNCIFY', '-sASYNCIFY_STACK_SIZE=4']
9187+
9188+
# The unreachable error on small stack sizes is not super-helpful. Try at
9189+
# least to hint at increasing the stack size.
9190+
9191+
def test(args, expected):
9192+
self.do_runf(test_file('other/test_asyncify_stack_overflow.cpp'),
9193+
emcc_args=args,
9194+
assert_returncode=common.NON_ZERO,
9195+
expected_output=[expected])
9196+
9197+
test(['-sASSERTIONS=0'],
9198+
'Aborted(RuntimeError: unreachable). Build with -sASSERTIONS for more info.')
9199+
9200+
test(['-sASSERTIONS=1'],
9201+
'Aborted(RuntimeError: unreachable). "unreachable" may be due to ASYNCIFY_STACK_SIZE not being large enough (try increasing it)')
9202+
91859203
# Sockets and networking
91869204

91879205
def test_inet(self):

0 commit comments

Comments
 (0)