Skip to content

Commit cf40c4d

Browse files
authored
Fix test_asyncify_lists* name detection (#16077)
Looking for 'name' in the binary leads to false positives with ASan and WasmFS that have that string in there for other reasons. Instead, use the shiny new wasm module parsing code Remove the TODO here and enable these tests in ASan mode.
1 parent 50bf997 commit cf40c4d

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

tests/test_core.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6755,6 +6755,10 @@ def test_demangle_stacks(self, extra_args):
67556755
# ensure function names are preserved
67566756
self.emcc_args += ['--profiling-funcs']
67576757
self.do_core_test('test_demangle_stacks.cpp', assert_returncode=NON_ZERO)
6758+
6759+
# there should be a name section in the file
6760+
self.assertTrue(webassembly.Module('test_demangle_stacks.wasm').has_name_section())
6761+
67586762
print('without assertions, the stack is not printed, but a message suggesting assertions is')
67596763
self.set_setting('ASSERTIONS', 0)
67606764
self.do_core_test('test_demangle_stacks_noassert.cpp', assert_returncode=NON_ZERO)
@@ -7598,14 +7602,12 @@ def test_asyncify_unused(self):
75987602
'onlylist_a': (['-sASYNCIFY_ONLY=["main","__original_main","foo(int, double)","baz()","c_baz","Structy::funcy()","bar()"]'], True),
75997603
'onlylist_b': (['-sASYNCIFY_ONLY=["main","__original_main","foo(int, double)","baz()","c_baz","Structy::funcy()"]'], True),
76007604
'onlylist_c': (['-sASYNCIFY_ONLY=["main","__original_main","foo(int, double)","baz()","c_baz"]'], False),
7601-
'onlylist_d': (['-sASYNCIFY_ONLY=["foo(int, double)","baz()","c_baz","Structy::funcy()"]'], False, None, True),
7605+
'onlylist_d': (['-sASYNCIFY_ONLY=["foo(int, double)","baz()","c_baz","Structy::funcy()"]'], False),
76027606
'onlylist_b_response': ([], True, '["main","__original_main","foo(int, double)","baz()","c_baz","Structy::funcy()"]'),
76037607
'onlylist_c_response': ([], False, '["main","__original_main","foo(int, double)","baz()","c_baz"]'),
76047608
})
76057609
@no_memory64('TODO: asyncify for wasm64')
7606-
def test_asyncify_lists(self, args, should_pass, response=None, no_san=False):
7607-
if no_san and is_sanitizing(self.emcc_args):
7608-
self.skipTest('remaining asyncify+sanitizer TODO')
7610+
def test_asyncify_lists(self, args, should_pass, response=None):
76097611
if response is not None:
76107612
create_file('response.file', response)
76117613
self.set_setting('ASYNCIFY_ONLY', '@response.file')
@@ -7619,15 +7621,15 @@ def test_asyncify_lists(self, args, should_pass, response=None, no_san=False):
76197621

76207622
# use of ASYNCIFY_* options may require intermediate debug info. that should
76217623
# not end up emitted in the final binary
7622-
# (note that we can't check this if sanitizers run, as they include a lot of
7623-
# static strings that would match the search)
7624-
if self.is_wasm() and not is_sanitizing(self.emcc_args):
7625-
binary = read_binary('test_asyncify_lists.wasm')
7626-
# there should be no name section
7627-
self.assertFalse(b'name' in binary)
7624+
if self.is_wasm():
7625+
filename = 'test_asyncify_lists.wasm'
7626+
# there should be no name section. sanitizers, however, always enable that
7627+
if not is_sanitizing(self.emcc_args):
7628+
self.assertFalse(webassembly.Module(filename).has_name_section())
76287629
# in a fully-optimized build, imports and exports are minified too and we
76297630
# can verify that our function names appear nowhere
76307631
if '-O3' in self.emcc_args:
7632+
binary = read_binary(filename)
76317633
self.assertFalse(b'main' in binary)
76327634

76337635
@parameterized({

tools/webassembly.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,12 @@ def get_tables(self):
387387

388388
return tables
389389

390+
def has_name_section(self):
391+
for section in self.sections():
392+
if section.type == SecType.CUSTOM and section.name == 'name':
393+
return True
394+
return False
395+
390396

391397
def parse_dylink_section(wasm_file):
392398
module = Module(wasm_file)

0 commit comments

Comments
 (0)