Skip to content

Run asan and lsan suites without -O2 #15176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2021
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
10 changes: 5 additions & 5 deletions tests/core/test_em_asm_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ int main()
i = EM_ASM_INT("{console.log('5. got int ' + $0); return 7.5;}", 42); printf("5. returned int %d\n", i);

printf("\nEM_ASM_INT: Return an integer in a single brief statement.\n");
i = EM_ASM_INT(return HEAP8.length); printf("1. returned statement %d\n", i);
i = EM_ASM_INT("return HEAP8.length+1"); printf("2. returned statement %d\n", i);
i = EM_ASM_INT({"return HEAP8.length+2"}); printf("3. returned statement %d\n", i);
i = EM_ASM_INT({return HEAP8.length+3}); printf("4. returned statement %d\n", i);
i = EM_ASM_INT("return HEAP8.length+4"); printf("5. returned statement %d\n", i);
i = EM_ASM_INT(return 42); printf("1. returned statement %d\n", i);
i = EM_ASM_INT("return 42+1"); printf("2. returned statement %d\n", i);
i = EM_ASM_INT({"return 42+2"}); printf("3. returned statement %d\n", i);
i = EM_ASM_INT({return 42+3}); printf("4. returned statement %d\n", i);
i = EM_ASM_INT("return 42+4"); printf("5. returned statement %d\n", i);

// Note that expressions do not evaluate to return values, but the "return" keyword is needed. That is, the following line would return undefined and store i <- 0.
// i = EM_ASM_INT(HEAP8.length); printf("returned statement %d\n", i);
Expand Down
10 changes: 5 additions & 5 deletions tests/core/test_em_asm_2.out
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ EM_ASM_INT: Return an integer back.
5. returned int 7

EM_ASM_INT: Return an integer in a single brief statement.
1. returned statement 16777216
2. returned statement 16777217
3. returned statement 16777218
4. returned statement 16777219
5. returned statement 16777220
1. returned statement 42
2. returned statement 43
3. returned statement 44
4. returned statement 45
5. returned statement 46

EM_ASM_DOUBLE: Pass no parameters, return a double.
1. returning double
Expand Down
3 changes: 1 addition & 2 deletions tests/core/test_emptyclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ struct Randomized {
};

int main(int argc, const char *argv[]) {
new Randomized(55);

Randomized(55);
return 0;
}
17 changes: 11 additions & 6 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class TestCoreBase(RunnerCore):
def is_wasm2js(self):
return self.get_setting('WASM') == 0

# A simple check whether the compiler arguments cause optimization.
# A simple check whether the compiler arguments cause optimization.
def is_optimizing(self):
return '-O' in str(self.emcc_args) and '-O0' not in self.emcc_args

Expand Down Expand Up @@ -1837,8 +1837,8 @@ def test_em_asm(self):
self.emcc_args.append('-std=gnu89')
self.do_core_test('test_em_asm.cpp', force_c=True)

# Tests various different ways to invoke the EM_ASM(), EM_ASM_INT() and EM_ASM_DOUBLE() macros.
@no_asan('Cannot use ASan: test depends exactly on heap size')
# Tests various different ways to invoke the EM_ASM(), EM_ASM_INT()
# and EM_ASM_DOUBLE() macros.
def test_em_asm_2(self):
self.do_core_test('test_em_asm_2.cpp')
self.emcc_args.append('-std=gnu89')
Expand Down Expand Up @@ -5944,6 +5944,10 @@ def test_ssse3(self):
@is_slow_test
def test_sse4_1(self):
src = test_file('sse/test_sse4_1.cpp')
if not self.is_optimizing() and '-fsanitize=address' in self.emcc_args:
# ASan with -O0 fails with:
# Compiling function #69:"__original_main" failed: local count too large
self.emcc_args.append('-O1')
self.run_process([shared.CLANG_CXX, src, '-msse4.1', '-Wno-argument-outside-range', '-o', 'test_sse4_1', '-D_CRT_SECURE_NO_WARNINGS=1'] + clang_native.get_clang_native_args(), stdout=PIPE)
native_result = self.run_process('./test_sse4_1', stdout=PIPE).stdout

Expand Down Expand Up @@ -7577,6 +7581,7 @@ def test_asyncify_indirect_lists(self, args, should_pass):
if should_pass:
raise

@no_asan('asyncify stack operations confuse asan')
def test_emscripten_scan_registers(self):
self.set_setting('ASYNCIFY')
self.do_core_test('test_emscripten_scan_registers.cpp')
Expand Down Expand Up @@ -8742,9 +8747,9 @@ def setUp(self):
# Add DEFAULT_TO_CXX=0
strict = make_run('strict', emcc_args=[], settings={'STRICT': 1})

lsan = make_run('lsan', emcc_args=['-fsanitize=leak', '--profiling', '-O2'], settings={'ALLOW_MEMORY_GROWTH': 1})
asan = make_run('asan', emcc_args=['-fsanitize=address', '--profiling', '-O2'], settings={'ALLOW_MEMORY_GROWTH': 1})
asani = make_run('asani', emcc_args=['-fsanitize=address', '--profiling', '-O2', '--pre-js', os.path.join(os.path.dirname(__file__), 'asan-no-leak.js')],
lsan = make_run('lsan', emcc_args=['-fsanitize=leak', '--profiling'], settings={'ALLOW_MEMORY_GROWTH': 1})
asan = make_run('asan', emcc_args=['-fsanitize=address', '--profiling'], settings={'ALLOW_MEMORY_GROWTH': 1})
asani = make_run('asani', emcc_args=['-fsanitize=address', '--profiling', '--pre-js', os.path.join(os.path.dirname(__file__), 'asan-no-leak.js')],
settings={'ALLOW_MEMORY_GROWTH': 1})

# Experimental modes (not tested by CI)
Expand Down