Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ jobs:
title: "asan+lsan"
test_targets: "
asan.test_stat
asan.test_stack
asan.test_float_builtins
asan.test_embind*
asan.test_abort_on_exceptions
Expand Down
2 changes: 1 addition & 1 deletion src/postamble_minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ function initRuntime(wasmExports) {

#if STACK_OVERFLOW_CHECK
_emscripten_stack_init();
writeStackCookie();
#if STACK_OVERFLOW_CHECK >= 2
setStackLimits();
#endif
writeStackCookie();
#endif

#if PTHREADS
Expand Down
8 changes: 4 additions & 4 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ function initRuntime() {
if (ENVIRONMENT_IS_PTHREAD) return startWorker(Module);
#endif

#if STACK_OVERFLOW_CHECK
checkStackCookie();
#endif

#if STACK_OVERFLOW_CHECK >= 2
setStackLimits();
#endif

#if STACK_OVERFLOW_CHECK
checkStackCookie();
#endif

#if RELOCATABLE
callRuntimeCallbacks(__RELOC_FUNCS__);
#endif
Expand Down
6 changes: 6 additions & 0 deletions test/core/test_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
* found in the LICENSE file.
*/

#include <assert.h>
#include <stdio.h>

int test(int i) {
int x = 10;
int ret = (long)&x; // both for the number, and forces x to not be nativized
Expand All @@ -17,11 +19,15 @@ int test(int i) {
}
return ret;
}

int main(int argc, char **argv) {
// We should get the same value for the first and last - stack has unwound
printf("in main\n");
int x1 = test(argc - 2);
int x2 = test(100);
int x3 = test((argc - 2) / 4);
assert(x2 != x1);
Comment thread
RReverser marked this conversation as resolved.
assert(x3 == x1);
printf("*%d,%d*\n", x3 - x1, x2 != x1);
return 0;
}