@@ -182,7 +182,8 @@ def can_do_standalone(self):
182
182
not self .get_setting ('MINIMAL_RUNTIME' ) and \
183
183
not self .get_setting ('SAFE_HEAP' ) and \
184
184
not self .get_setting ('MEMORY64' ) and \
185
- '-fsanitize=address' not in self .emcc_args
185
+ '-fsanitize=address' not in self .emcc_args and \
186
+ '-fsanitize=leak' not in self .emcc_args
186
187
187
188
188
189
def also_with_wasmfs (func ):
@@ -660,6 +661,7 @@ def test_align64(self):
660
661
''' )
661
662
662
663
@no_asan ('asan errors on corner cases we check' )
664
+ @no_lsan ('lsan errors on corner cases we check' )
663
665
def test_aligned_alloc (self ):
664
666
self .do_runf (test_file ('test_aligned_alloc.c' ), '' ,
665
667
emcc_args = ['-Wno-non-power-of-two-alignment' ])
@@ -873,6 +875,7 @@ def test_stack_placement(self):
873
875
self .do_core_test ('test_stack_placement.c' )
874
876
875
877
@no_asan ('asan does not support main modules' )
878
+ @no_lsan ('asan does not support main modules' )
876
879
@no_wasm2js ('MAIN_MODULE support' )
877
880
def test_stack_placement_pic (self ):
878
881
self .set_setting ('TOTAL_STACK' , 1024 )
@@ -1282,7 +1285,8 @@ def test_exceptions_allowed(self):
1282
1285
# empty list acts the same as fully disabled
1283
1286
self .assertEqual (empty_size , disabled_size )
1284
1287
# big change when we disable exception catching of the function
1285
- self .assertGreater (size - empty_size , 0.01 * size )
1288
+ if '-fsanitize=leak' not in self .emcc_args :
1289
+ self .assertGreater (size - empty_size , 0.01 * size )
1286
1290
# full disable can remove a little bit more
1287
1291
self .assertLess (disabled_size , fake_size )
1288
1292
@@ -1567,6 +1571,7 @@ def test_segfault(self):
1567
1571
1568
1572
struct Classey {
1569
1573
virtual void doIt() = 0;
1574
+ virtual ~Classey() = default;
1570
1575
};
1571
1576
1572
1577
struct D1 : Classey {
@@ -1581,11 +1586,11 @@ def test_segfault(self):
1581
1586
return 0;
1582
1587
});
1583
1588
1584
- int main(int argc, char **argv)
1585
- {
1589
+ int main(int argc, char **argv) {
1586
1590
Classey *p = argc == 100 ? new D1() : (Classey*)%s;
1587
1591
1588
1592
p->doIt();
1593
+ delete p;
1589
1594
1590
1595
return 0;
1591
1596
}
@@ -1767,16 +1772,17 @@ def test_set_align(self):
1767
1772
1768
1773
self .do_core_test ('test_set_align.c' )
1769
1774
1770
- @no_asan ('EXPORT_ALL is not compatible with Asan' )
1771
1775
def test_emscripten_api (self ):
1772
1776
self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_save_me_aimee' ])
1773
1777
self .do_core_test ('test_emscripten_api.cpp' )
1774
1778
1775
- # test EXPORT_ALL
1776
- self .set_setting ('EXPORTED_FUNCTIONS' , [])
1777
- self .set_setting ('EXPORT_ALL' )
1778
- self .set_setting ('LINKABLE' )
1779
- self .do_core_test ('test_emscripten_api.cpp' )
1779
+ # Sanitizers are not compatible with LINKABLE (dynamic linking.
1780
+ if not is_sanitizing (self .emcc_args ):
1781
+ # test EXPORT_ALL
1782
+ self .set_setting ('EXPORTED_FUNCTIONS' , [])
1783
+ self .set_setting ('EXPORT_ALL' )
1784
+ self .set_setting ('LINKABLE' )
1785
+ self .do_core_test ('test_emscripten_api.cpp' )
1780
1786
1781
1787
def test_emscripten_run_script_string_int (self ):
1782
1788
src = r'''
@@ -1921,7 +1927,6 @@ def test_em_asm_2(self):
1921
1927
# Tests various different ways to invoke the MAIN_THREAD_EM_ASM(), MAIN_THREAD_EM_ASM_INT() and MAIN_THREAD_EM_ASM_DOUBLE() macros.
1922
1928
# This test is identical to test_em_asm_2, just search-replaces EM_ASM to MAIN_THREAD_EM_ASM on the test file. That way if new
1923
1929
# test cases are added to test_em_asm_2.cpp for EM_ASM, they will also get tested in MAIN_THREAD_EM_ASM form.
1924
- @no_asan ('Cannot use ASan: test depends exactly on heap size' )
1925
1930
def test_main_thread_em_asm (self ):
1926
1931
src = read_file (test_file ('core/test_em_asm_2.cpp' ))
1927
1932
create_file ('src.cpp' , src .replace ('EM_ASM' , 'MAIN_THREAD_EM_ASM' ))
@@ -1972,10 +1977,8 @@ def test_em_asm_direct(self):
1972
1977
'linked_c' : (['-s' , 'MAIN_MODULE' ], True ),
1973
1978
})
1974
1979
def test_em_js (self , args , force_c ):
1975
- if 'MAIN_MODULE' in args and not self .is_wasm ():
1976
- self .skipTest ('main module support for non-wasm' )
1977
- if '-fsanitize=address' in self .emcc_args :
1978
- self .skipTest ('no dynamic library support in asan yet' )
1980
+ if 'MAIN_MODULE' in args :
1981
+ self .check_dylink ()
1979
1982
self .emcc_args += args + ['-s' , 'EXPORTED_FUNCTIONS=_main,_malloc' ]
1980
1983
1981
1984
self .do_core_test ('test_em_js.cpp' , force_c = force_c )
@@ -2108,6 +2111,7 @@ def test_memorygrowth_3_force_fail_reallocBuffer(self):
2108
2111
'grow' : (['-sALLOW_MEMORY_GROWTH' , '-sMAXIMUM_MEMORY=18MB' ],)
2109
2112
})
2110
2113
@no_asan ('requires more memory when growing' )
2114
+ @no_lsan ('requires more memory when growing' )
2111
2115
@no_memory64 ('does not fail under wasm64' )
2112
2116
def test_aborting_new (self , args ):
2113
2117
# test that C++ new properly errors if we fail to malloc when growth is
@@ -2117,6 +2121,7 @@ def test_aborting_new(self, args):
2117
2121
2118
2122
@no_wasm2js ('no WebAssembly.Memory()' )
2119
2123
@no_asan ('ASan alters the memory size' )
2124
+ @no_lsan ('LSan alters the memory size' )
2120
2125
def test_module_wasm_memory (self ):
2121
2126
self .emcc_args += ['--pre-js' , test_file ('core/test_module_wasm_memory.js' )]
2122
2127
self .set_setting ('IMPORTED_MEMORY' )
@@ -2402,6 +2407,7 @@ def test_atexit(self):
2402
2407
self .set_setting ('EXIT_RUNTIME' )
2403
2408
self .do_core_test ('test_atexit.c' )
2404
2409
2410
+ @no_lsan ('https://github.com/emscripten-core/emscripten/issues/15988' )
2405
2411
def test_atexit_threads_stub (self ):
2406
2412
# also tests thread exit (__cxa_thread_atexit)
2407
2413
self .set_setting ('EXIT_RUNTIME' )
@@ -5288,6 +5294,7 @@ def test_utf8_invalid(self):
5288
5294
def test_minimal_runtime_utf8_invalid (self ):
5289
5295
self .set_setting ('EXPORTED_RUNTIME_METHODS' , ['UTF8ToString' , 'stringToUTF8' ])
5290
5296
self .set_setting ('MINIMAL_RUNTIME' )
5297
+ self .emcc_args += ['--pre-js' , test_file ('minimal_runtime_exit_handling.js' )]
5291
5298
for decoder_mode in [False , True ]:
5292
5299
self .set_setting ('TEXTDECODER' , decoder_mode )
5293
5300
print (str (decoder_mode ))
@@ -5845,6 +5852,7 @@ def test_whets(self):
5845
5852
# node is slower, and fail on 64-bit
5846
5853
@require_v8
5847
5854
@no_asan ('depends on the specifics of memory size, which for asan we are forced to increase' )
5855
+ @no_lsan ('depends on the specifics of memory size, which for lsan we are forced to increase' )
5848
5856
def test_dlmalloc_inline (self ):
5849
5857
# needed with typed arrays
5850
5858
self .set_setting ('INITIAL_MEMORY' , '128mb' )
@@ -5856,6 +5864,7 @@ def test_dlmalloc_inline(self):
5856
5864
# node is slower, and fail on 64-bit
5857
5865
@require_v8
5858
5866
@no_asan ('depends on the specifics of memory size, which for asan we are forced to increase' )
5867
+ @no_lsan ('depends on the specifics of memory size, which for lsan we are forced to increase' )
5859
5868
def test_dlmalloc (self ):
5860
5869
# needed with typed arrays
5861
5870
self .set_setting ('INITIAL_MEMORY' , '128mb' )
@@ -5887,11 +5896,13 @@ def test_dlmalloc(self):
5887
5896
5888
5897
# Tests that a large allocation should gracefully fail
5889
5898
@no_asan ('the memory size limit here is too small for asan' )
5899
+ @no_lsan ('the memory size limit here is too small for lsan' )
5890
5900
def test_dlmalloc_large (self ):
5891
5901
self .emcc_args += ['-s' , 'ABORTING_MALLOC=0' , '-s' , 'ALLOW_MEMORY_GROWTH=1' , '-s' , 'MAXIMUM_MEMORY=128MB' ]
5892
5902
self .do_runf (test_file ('dlmalloc_test_large.c' ), '0 0 0 1' )
5893
5903
5894
5904
@no_asan ('asan also changes malloc, and that ends up linking in new twice' )
5905
+ @no_lsan ('lsan also changes malloc, and that ends up linking in new twice' )
5895
5906
def test_dlmalloc_partial (self ):
5896
5907
# present part of the symbols of dlmalloc, not all
5897
5908
src = read_file (test_file ('new.cpp' )).replace ('{{{ NEW }}}' , 'new int' ).replace ('{{{ DELETE }}}' , 'delete' ) + '''
@@ -5905,6 +5916,7 @@ def test_dlmalloc_partial(self):
5905
5916
self .do_run (src , 'new 4!\n *1,0*' )
5906
5917
5907
5918
@no_asan ('asan also changes malloc, and that ends up linking in new twice' )
5919
+ @no_lsan ('lsan also changes malloc, and that ends up linking in new twice' )
5908
5920
def test_dlmalloc_partial_2 (self ):
5909
5921
if 'SAFE_HEAP' in str (self .emcc_args ):
5910
5922
self .skipTest ('we do unsafe stuff here' )
@@ -6397,7 +6409,7 @@ def do_test():
6397
6409
self .set_setting ('ALLOW_MEMORY_GROWTH' , 0 )
6398
6410
do_test ()
6399
6411
6400
- if '-fsanitize=address' in self .emcc_args :
6412
+ if is_sanitizing ( self .emcc_args ) :
6401
6413
# In ASan mode we need a large initial memory (or else wasm-ld fails).
6402
6414
# The OpenJPEG CMake will build several executables (which we need parts
6403
6415
# of in our testing, see above), so we must enable the flag for them all.
@@ -7715,6 +7727,7 @@ def test_asyncify_during_exit(self):
7715
7727
self .do_core_test ('test_asyncify_during_exit.cpp' , emcc_args = ['-DNO_ASYNC' ], out_suffix = '_no_async' )
7716
7728
7717
7729
@no_asan ('asyncify stack operations confuse asan' )
7730
+ @no_lsan ('undefined symbol __global_base' )
7718
7731
@no_wasm2js ('dynamic linking support in wasm2js' )
7719
7732
def test_asyncify_main_module (self ):
7720
7733
self .set_setting ('ASYNCIFY' , 1 )
@@ -7741,7 +7754,7 @@ def test_emscripten_lazy_load_code(self, conditional):
7741
7754
second_size = os .path .getsize ('emscripten_lazy_load_code.wasm.lazy.wasm' )
7742
7755
print ('first wasm size' , first_size )
7743
7756
print ('second wasm size' , second_size )
7744
- if not conditional and self .is_optimizing () and '-g' not in self .emcc_args :
7757
+ if not conditional and self .is_optimizing () and '-g' not in self .emcc_args and '-fsanitize=leak' not in self . emcc_args :
7745
7758
# If the call to lazy-load is unconditional, then the optimizer can dce
7746
7759
# out more than half
7747
7760
self .assertLess (first_size , 0.6 * second_size )
@@ -7806,6 +7819,7 @@ def verify_broken(args=['0']):
7806
7819
7807
7820
# Test basic wasm2js functionality in all core compilation modes.
7808
7821
@no_asan ('no wasm2js support yet in asan' )
7822
+ @no_lsan ('no wasm2js support yet in lsan' )
7809
7823
def test_wasm2js (self ):
7810
7824
if not self .is_wasm ():
7811
7825
self .skipTest ('redundant to test wasm2js in wasm2js* mode' )
@@ -7821,6 +7835,7 @@ def test_wasm2js(self):
7821
7835
self .assertNotExists ('test_hello_world.js.mem' )
7822
7836
7823
7837
@no_asan ('no wasm2js support yet in asan' )
7838
+ @no_lsan ('no wasm2js support yet in lsan' )
7824
7839
def test_maybe_wasm2js (self ):
7825
7840
if not self .is_wasm ():
7826
7841
self .skipTest ('redundant to test wasm2js in wasm2js* mode' )
@@ -7990,10 +8005,12 @@ def test_brk(self):
7990
8005
# Tests that we can use the dlmalloc mallinfo() function to obtain information
7991
8006
# about malloc()ed blocks and compute how much memory is used/freed.
7992
8007
@no_asan ('mallinfo is not part of ASan malloc' )
8008
+ @no_lsan ('mallinfo is not part of LSan malloc' )
7993
8009
def test_mallinfo (self ):
7994
8010
self .do_runf (test_file ('mallinfo.cpp' ), 'OK.' )
7995
8011
7996
8012
@no_asan ('cannot replace malloc/free with ASan' )
8013
+ @no_lsan ('cannot replace malloc/free with LSan' )
7997
8014
def test_wrap_malloc (self ):
7998
8015
self .do_runf (test_file ('wrap_malloc.cpp' ), 'OK.' )
7999
8016
@@ -8070,6 +8087,7 @@ def test_minimal_runtime_no_declare_asm_module_exports(self):
8070
8087
self .set_setting ('WASM_ASYNC_COMPILATION' , 0 )
8071
8088
self .maybe_closure ()
8072
8089
self .set_setting ('MINIMAL_RUNTIME' )
8090
+ self .emcc_args += ['--pre-js' , test_file ('minimal_runtime_exit_handling.js' )]
8073
8091
self .do_runf (test_file ('declare_asm_module_exports.cpp' ), 'jsFunction: 1' )
8074
8092
8075
8093
# Tests that -s MINIMAL_RUNTIME=1 works well in different build modes
@@ -8095,6 +8113,7 @@ def test_minimal_runtime_hello_world(self, args):
8095
8113
@no_asan ('TODO: ASan support in minimal runtime' )
8096
8114
def test_minimal_runtime_hello_printf (self , extra_setting ):
8097
8115
self .set_setting ('MINIMAL_RUNTIME' )
8116
+ self .emcc_args += ['--pre-js' , test_file ('minimal_runtime_exit_handling.js' )]
8098
8117
self .set_setting (extra_setting )
8099
8118
# $FS is not fully compatible with MINIMAL_RUNTIME so fails with closure
8100
8119
# compiler. lsan also pulls in $FS
@@ -8106,6 +8125,7 @@ def test_minimal_runtime_hello_printf(self, extra_setting):
8106
8125
@no_asan ('TODO: ASan support in minimal runtime' )
8107
8126
def test_minimal_runtime_safe_heap (self ):
8108
8127
self .set_setting ('MINIMAL_RUNTIME' )
8128
+ self .emcc_args += ['--pre-js' , test_file ('minimal_runtime_exit_handling.js' )]
8109
8129
self .set_setting ('SAFE_HEAP' )
8110
8130
# $FS is not fully compatible with MINIMAL_RUNTIME so fails with closure
8111
8131
# compiler.
@@ -8118,6 +8138,7 @@ def test_minimal_runtime_safe_heap(self):
8118
8138
@no_asan ('TODO: ASan support in minimal runtime' )
8119
8139
def test_minimal_runtime_global_initializer (self ):
8120
8140
self .set_setting ('MINIMAL_RUNTIME' )
8141
+ self .emcc_args += ['--pre-js' , test_file ('minimal_runtime_exit_handling.js' )]
8121
8142
self .maybe_closure ()
8122
8143
self .do_runf (test_file ('test_global_initializer.cpp' ), 't1 > t0: 1' )
8123
8144
@@ -8128,6 +8149,7 @@ def test_return_address(self):
8128
8149
8129
8150
@no_wasm2js ('TODO: sanitizers in wasm2js' )
8130
8151
@no_asan ('-fsanitize-minimal-runtime cannot be used with ASan' )
8152
+ @no_lsan ('-fsanitize-minimal-runtime cannot be used with LSan' )
8131
8153
def test_ubsan_minimal_too_many_errors (self ):
8132
8154
self .emcc_args += ['-fsanitize=undefined' , '-fsanitize-minimal-runtime' ]
8133
8155
if not self .is_wasm ():
@@ -8140,6 +8162,7 @@ def test_ubsan_minimal_too_many_errors(self):
8140
8162
8141
8163
@no_wasm2js ('TODO: sanitizers in wasm2js' )
8142
8164
@no_asan ('-fsanitize-minimal-runtime cannot be used with ASan' )
8165
+ @no_lsan ('-fsanitize-minimal-runtime cannot be used with LSan' )
8143
8166
def test_ubsan_minimal_errors_same_place (self ):
8144
8167
self .emcc_args += ['-fsanitize=undefined' , '-fsanitize-minimal-runtime' ]
8145
8168
if not self .is_wasm ():
@@ -8708,6 +8731,7 @@ def test_minimal_runtime_emscripten_get_exported_function(self):
8708
8731
# Could also test with -s ALLOW_TABLE_GROWTH=1
8709
8732
self .set_setting ('RESERVED_FUNCTION_POINTERS' , 2 )
8710
8733
self .set_setting ('MINIMAL_RUNTIME' )
8734
+ self .emcc_args += ['--pre-js' , test_file ('minimal_runtime_exit_handling.js' )]
8711
8735
self .emcc_args += ['-lexports.js' ]
8712
8736
self .do_core_test ('test_get_exported_function.cpp' )
8713
8737
0 commit comments