@@ -184,7 +184,8 @@ def can_do_standalone(self):
184
184
not self .get_setting ('MINIMAL_RUNTIME' ) and \
185
185
not self .get_setting ('SAFE_HEAP' ) and \
186
186
not self .get_setting ('MEMORY64' ) and \
187
- '-fsanitize=address' not in self .emcc_args
187
+ '-fsanitize=address' not in self .emcc_args and \
188
+ '-fsanitize=leak' not in self .emcc_args
188
189
189
190
190
191
def also_with_wasmfs (func ):
@@ -662,6 +663,7 @@ def test_align64(self):
662
663
''' )
663
664
664
665
@no_asan ('asan errors on corner cases we check' )
666
+ @no_lsan ('lsan errors on corner cases we check' )
665
667
def test_aligned_alloc (self ):
666
668
self .do_runf (test_file ('test_aligned_alloc.c' ), '' ,
667
669
emcc_args = ['-Wno-non-power-of-two-alignment' ])
@@ -875,6 +877,7 @@ def test_stack_placement(self):
875
877
self .do_core_test ('test_stack_placement.c' )
876
878
877
879
@no_asan ('asan does not support main modules' )
880
+ @no_lsan ('asan does not support main modules' )
878
881
@no_wasm2js ('MAIN_MODULE support' )
879
882
def test_stack_placement_pic (self ):
880
883
self .set_setting ('TOTAL_STACK' , 1024 )
@@ -1284,7 +1287,8 @@ def test_exceptions_allowed(self):
1284
1287
# empty list acts the same as fully disabled
1285
1288
self .assertEqual (empty_size , disabled_size )
1286
1289
# big change when we disable exception catching of the function
1287
- self .assertGreater (size - empty_size , 0.01 * size )
1290
+ if '-fsanitize=leak' not in self .emcc_args :
1291
+ self .assertGreater (size - empty_size , 0.01 * size )
1288
1292
# full disable can remove a little bit more
1289
1293
self .assertLess (disabled_size , fake_size )
1290
1294
@@ -1569,6 +1573,7 @@ def test_segfault(self):
1569
1573
1570
1574
struct Classey {
1571
1575
virtual void doIt() = 0;
1576
+ virtual ~Classey() = default;
1572
1577
};
1573
1578
1574
1579
struct D1 : Classey {
@@ -1583,11 +1588,11 @@ def test_segfault(self):
1583
1588
return 0;
1584
1589
});
1585
1590
1586
- int main(int argc, char **argv)
1587
- {
1591
+ int main(int argc, char **argv) {
1588
1592
Classey *p = argc == 100 ? new D1() : (Classey*)%s;
1589
1593
1590
1594
p->doIt();
1595
+ delete p;
1591
1596
1592
1597
return 0;
1593
1598
}
@@ -1769,16 +1774,17 @@ def test_set_align(self):
1769
1774
1770
1775
self .do_core_test ('test_set_align.c' )
1771
1776
1772
- @no_asan ('EXPORT_ALL is not compatible with Asan' )
1773
1777
def test_emscripten_api (self ):
1774
1778
self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_save_me_aimee' ])
1775
1779
self .do_core_test ('test_emscripten_api.cpp' )
1776
1780
1777
- # test EXPORT_ALL
1778
- self .set_setting ('EXPORTED_FUNCTIONS' , [])
1779
- self .set_setting ('EXPORT_ALL' )
1780
- self .set_setting ('LINKABLE' )
1781
- self .do_core_test ('test_emscripten_api.cpp' )
1781
+ # Sanitizers are not compatible with LINKABLE (dynamic linking.
1782
+ if not is_sanitizing (self .emcc_args ):
1783
+ # test EXPORT_ALL
1784
+ self .set_setting ('EXPORTED_FUNCTIONS' , [])
1785
+ self .set_setting ('EXPORT_ALL' )
1786
+ self .set_setting ('LINKABLE' )
1787
+ self .do_core_test ('test_emscripten_api.cpp' )
1782
1788
1783
1789
def test_emscripten_run_script_string_int (self ):
1784
1790
src = r'''
@@ -1923,7 +1929,6 @@ def test_em_asm_2(self):
1923
1929
# Tests various different ways to invoke the MAIN_THREAD_EM_ASM(), MAIN_THREAD_EM_ASM_INT() and MAIN_THREAD_EM_ASM_DOUBLE() macros.
1924
1930
# 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
1925
1931
# test cases are added to test_em_asm_2.cpp for EM_ASM, they will also get tested in MAIN_THREAD_EM_ASM form.
1926
- @no_asan ('Cannot use ASan: test depends exactly on heap size' )
1927
1932
def test_main_thread_em_asm (self ):
1928
1933
src = read_file (test_file ('core/test_em_asm_2.cpp' ))
1929
1934
create_file ('src.cpp' , src .replace ('EM_ASM' , 'MAIN_THREAD_EM_ASM' ))
@@ -1974,10 +1979,8 @@ def test_em_asm_direct(self):
1974
1979
'linked_c' : (['-s' , 'MAIN_MODULE' ], True ),
1975
1980
})
1976
1981
def test_em_js (self , args , force_c ):
1977
- if 'MAIN_MODULE' in args and not self .is_wasm ():
1978
- self .skipTest ('main module support for non-wasm' )
1979
- if '-fsanitize=address' in self .emcc_args :
1980
- self .skipTest ('no dynamic library support in asan yet' )
1982
+ if 'MAIN_MODULE' in args :
1983
+ self .check_dylink ()
1981
1984
self .emcc_args += args + ['-s' , 'EXPORTED_FUNCTIONS=_main,_malloc' ]
1982
1985
1983
1986
self .do_core_test ('test_em_js.cpp' , force_c = force_c )
@@ -2110,6 +2113,7 @@ def test_memorygrowth_3_force_fail_reallocBuffer(self):
2110
2113
'grow' : (['-sALLOW_MEMORY_GROWTH' , '-sMAXIMUM_MEMORY=18MB' ],)
2111
2114
})
2112
2115
@no_asan ('requires more memory when growing' )
2116
+ @no_lsan ('requires more memory when growing' )
2113
2117
@no_memory64 ('does not fail under wasm64' )
2114
2118
def test_aborting_new (self , args ):
2115
2119
# test that C++ new properly errors if we fail to malloc when growth is
@@ -2119,6 +2123,7 @@ def test_aborting_new(self, args):
2119
2123
2120
2124
@no_wasm2js ('no WebAssembly.Memory()' )
2121
2125
@no_asan ('ASan alters the memory size' )
2126
+ @no_lsan ('LSan alters the memory size' )
2122
2127
def test_module_wasm_memory (self ):
2123
2128
self .emcc_args += ['--pre-js' , test_file ('core/test_module_wasm_memory.js' )]
2124
2129
self .set_setting ('IMPORTED_MEMORY' )
@@ -5290,6 +5295,7 @@ def test_utf8_invalid(self):
5290
5295
def test_minimal_runtime_utf8_invalid (self ):
5291
5296
self .set_setting ('EXPORTED_RUNTIME_METHODS' , ['UTF8ToString' , 'stringToUTF8' ])
5292
5297
self .set_setting ('MINIMAL_RUNTIME' )
5298
+ self .emcc_args += ['--pre-js' , test_file ('minimal_runtime_exit_handling.js' )]
5293
5299
for decoder_mode in [False , True ]:
5294
5300
self .set_setting ('TEXTDECODER' , decoder_mode )
5295
5301
print (str (decoder_mode ))
@@ -5847,6 +5853,7 @@ def test_whets(self):
5847
5853
# node is slower, and fail on 64-bit
5848
5854
@require_v8
5849
5855
@no_asan ('depends on the specifics of memory size, which for asan we are forced to increase' )
5856
+ @no_lsan ('depends on the specifics of memory size, which for lsan we are forced to increase' )
5850
5857
def test_dlmalloc_inline (self ):
5851
5858
# needed with typed arrays
5852
5859
self .set_setting ('INITIAL_MEMORY' , '128mb' )
@@ -5858,6 +5865,7 @@ def test_dlmalloc_inline(self):
5858
5865
# node is slower, and fail on 64-bit
5859
5866
@require_v8
5860
5867
@no_asan ('depends on the specifics of memory size, which for asan we are forced to increase' )
5868
+ @no_lsan ('depends on the specifics of memory size, which for lsan we are forced to increase' )
5861
5869
def test_dlmalloc (self ):
5862
5870
# needed with typed arrays
5863
5871
self .set_setting ('INITIAL_MEMORY' , '128mb' )
@@ -5889,11 +5897,13 @@ def test_dlmalloc(self):
5889
5897
5890
5898
# Tests that a large allocation should gracefully fail
5891
5899
@no_asan ('the memory size limit here is too small for asan' )
5900
+ @no_lsan ('the memory size limit here is too small for lsan' )
5892
5901
def test_dlmalloc_large (self ):
5893
5902
self .emcc_args += ['-s' , 'ABORTING_MALLOC=0' , '-s' , 'ALLOW_MEMORY_GROWTH=1' , '-s' , 'MAXIMUM_MEMORY=128MB' ]
5894
5903
self .do_runf (test_file ('dlmalloc_test_large.c' ), '0 0 0 1' )
5895
5904
5896
5905
@no_asan ('asan also changes malloc, and that ends up linking in new twice' )
5906
+ @no_lsan ('lsan also changes malloc, and that ends up linking in new twice' )
5897
5907
def test_dlmalloc_partial (self ):
5898
5908
# present part of the symbols of dlmalloc, not all
5899
5909
src = read_file (test_file ('new.cpp' )).replace ('{{{ NEW }}}' , 'new int' ).replace ('{{{ DELETE }}}' , 'delete' ) + '''
@@ -5907,6 +5917,7 @@ def test_dlmalloc_partial(self):
5907
5917
self .do_run (src , 'new 4!\n *1,0*' )
5908
5918
5909
5919
@no_asan ('asan also changes malloc, and that ends up linking in new twice' )
5920
+ @no_lsan ('lsan also changes malloc, and that ends up linking in new twice' )
5910
5921
def test_dlmalloc_partial_2 (self ):
5911
5922
if 'SAFE_HEAP' in str (self .emcc_args ):
5912
5923
self .skipTest ('we do unsafe stuff here' )
@@ -6400,7 +6411,7 @@ def do_test():
6400
6411
self .set_setting ('ALLOW_MEMORY_GROWTH' , 0 )
6401
6412
do_test ()
6402
6413
6403
- if '-fsanitize=address' in self .emcc_args :
6414
+ if is_sanitizing ( self .emcc_args ) :
6404
6415
# In ASan mode we need a large initial memory (or else wasm-ld fails).
6405
6416
# The OpenJPEG CMake will build several executables (which we need parts
6406
6417
# of in our testing, see above), so we must enable the flag for them all.
@@ -7718,6 +7729,7 @@ def test_asyncify_during_exit(self):
7718
7729
self .do_core_test ('test_asyncify_during_exit.cpp' , emcc_args = ['-DNO_ASYNC' ], out_suffix = '_no_async' )
7719
7730
7720
7731
@no_asan ('asyncify stack operations confuse asan' )
7732
+ @no_lsan ('undefined symbol __global_base' )
7721
7733
@no_wasm2js ('dynamic linking support in wasm2js' )
7722
7734
def test_asyncify_main_module (self ):
7723
7735
self .set_setting ('ASYNCIFY' , 1 )
@@ -7744,7 +7756,7 @@ def test_emscripten_lazy_load_code(self, conditional):
7744
7756
second_size = os .path .getsize ('emscripten_lazy_load_code.wasm.lazy.wasm' )
7745
7757
print ('first wasm size' , first_size )
7746
7758
print ('second wasm size' , second_size )
7747
- if not conditional and self .is_optimizing () and '-g' not in self .emcc_args :
7759
+ if not conditional and self .is_optimizing () and '-g' not in self .emcc_args and '-fsanitize=leak' not in self . emcc_args :
7748
7760
# If the call to lazy-load is unconditional, then the optimizer can dce
7749
7761
# out more than half
7750
7762
self .assertLess (first_size , 0.6 * second_size )
@@ -7809,6 +7821,7 @@ def verify_broken(args=['0']):
7809
7821
7810
7822
# Test basic wasm2js functionality in all core compilation modes.
7811
7823
@no_asan ('no wasm2js support yet in asan' )
7824
+ @no_lsan ('no wasm2js support yet in lsan' )
7812
7825
def test_wasm2js (self ):
7813
7826
if not self .is_wasm ():
7814
7827
self .skipTest ('redundant to test wasm2js in wasm2js* mode' )
@@ -7824,6 +7837,7 @@ def test_wasm2js(self):
7824
7837
self .assertNotExists ('test_hello_world.js.mem' )
7825
7838
7826
7839
@no_asan ('no wasm2js support yet in asan' )
7840
+ @no_lsan ('no wasm2js support yet in lsan' )
7827
7841
def test_maybe_wasm2js (self ):
7828
7842
if not self .is_wasm ():
7829
7843
self .skipTest ('redundant to test wasm2js in wasm2js* mode' )
@@ -7993,10 +8007,12 @@ def test_brk(self):
7993
8007
# Tests that we can use the dlmalloc mallinfo() function to obtain information
7994
8008
# about malloc()ed blocks and compute how much memory is used/freed.
7995
8009
@no_asan ('mallinfo is not part of ASan malloc' )
8010
+ @no_lsan ('mallinfo is not part of LSan malloc' )
7996
8011
def test_mallinfo (self ):
7997
8012
self .do_runf (test_file ('mallinfo.cpp' ), 'OK.' )
7998
8013
7999
8014
@no_asan ('cannot replace malloc/free with ASan' )
8015
+ @no_lsan ('cannot replace malloc/free with LSan' )
8000
8016
def test_wrap_malloc (self ):
8001
8017
self .do_runf (test_file ('wrap_malloc.cpp' ), 'OK.' )
8002
8018
@@ -8073,6 +8089,7 @@ def test_minimal_runtime_no_declare_asm_module_exports(self):
8073
8089
self .set_setting ('WASM_ASYNC_COMPILATION' , 0 )
8074
8090
self .maybe_closure ()
8075
8091
self .set_setting ('MINIMAL_RUNTIME' )
8092
+ self .emcc_args += ['--pre-js' , test_file ('minimal_runtime_exit_handling.js' )]
8076
8093
self .do_runf (test_file ('declare_asm_module_exports.cpp' ), 'jsFunction: 1' )
8077
8094
8078
8095
# Tests that -s MINIMAL_RUNTIME=1 works well in different build modes
@@ -8098,6 +8115,7 @@ def test_minimal_runtime_hello_world(self, args):
8098
8115
@no_asan ('TODO: ASan support in minimal runtime' )
8099
8116
def test_minimal_runtime_hello_printf (self , extra_setting ):
8100
8117
self .set_setting ('MINIMAL_RUNTIME' )
8118
+ self .emcc_args += ['--pre-js' , test_file ('minimal_runtime_exit_handling.js' )]
8101
8119
self .set_setting (extra_setting )
8102
8120
# $FS is not fully compatible with MINIMAL_RUNTIME so fails with closure
8103
8121
# compiler. lsan also pulls in $FS
@@ -8109,6 +8127,7 @@ def test_minimal_runtime_hello_printf(self, extra_setting):
8109
8127
@no_asan ('TODO: ASan support in minimal runtime' )
8110
8128
def test_minimal_runtime_safe_heap (self ):
8111
8129
self .set_setting ('MINIMAL_RUNTIME' )
8130
+ self .emcc_args += ['--pre-js' , test_file ('minimal_runtime_exit_handling.js' )]
8112
8131
self .set_setting ('SAFE_HEAP' )
8113
8132
# $FS is not fully compatible with MINIMAL_RUNTIME so fails with closure
8114
8133
# compiler.
@@ -8121,6 +8140,7 @@ def test_minimal_runtime_safe_heap(self):
8121
8140
@no_asan ('TODO: ASan support in minimal runtime' )
8122
8141
def test_minimal_runtime_global_initializer (self ):
8123
8142
self .set_setting ('MINIMAL_RUNTIME' )
8143
+ self .emcc_args += ['--pre-js' , test_file ('minimal_runtime_exit_handling.js' )]
8124
8144
self .maybe_closure ()
8125
8145
self .do_runf (test_file ('test_global_initializer.cpp' ), 't1 > t0: 1' )
8126
8146
@@ -8131,6 +8151,7 @@ def test_return_address(self):
8131
8151
8132
8152
@no_wasm2js ('TODO: sanitizers in wasm2js' )
8133
8153
@no_asan ('-fsanitize-minimal-runtime cannot be used with ASan' )
8154
+ @no_lsan ('-fsanitize-minimal-runtime cannot be used with LSan' )
8134
8155
def test_ubsan_minimal_too_many_errors (self ):
8135
8156
self .emcc_args += ['-fsanitize=undefined' , '-fsanitize-minimal-runtime' ]
8136
8157
if not self .is_wasm ():
@@ -8143,6 +8164,7 @@ def test_ubsan_minimal_too_many_errors(self):
8143
8164
8144
8165
@no_wasm2js ('TODO: sanitizers in wasm2js' )
8145
8166
@no_asan ('-fsanitize-minimal-runtime cannot be used with ASan' )
8167
+ @no_lsan ('-fsanitize-minimal-runtime cannot be used with LSan' )
8146
8168
def test_ubsan_minimal_errors_same_place (self ):
8147
8169
self .emcc_args += ['-fsanitize=undefined' , '-fsanitize-minimal-runtime' ]
8148
8170
if not self .is_wasm ():
@@ -8701,6 +8723,7 @@ def test_minimal_runtime_emscripten_get_exported_function(self):
8701
8723
# Could also test with -s ALLOW_TABLE_GROWTH=1
8702
8724
self .set_setting ('RESERVED_FUNCTION_POINTERS' , 2 )
8703
8725
self .set_setting ('MINIMAL_RUNTIME' )
8726
+ self .emcc_args += ['--pre-js' , test_file ('minimal_runtime_exit_handling.js' )]
8704
8727
self .emcc_args += ['-lexports.js' ]
8705
8728
self .do_core_test ('test_get_exported_function.cpp' )
8706
8729
0 commit comments