Skip to content

Commit a0bb468

Browse files
committed
fix case of exceptions whitelist being empty
1 parent 079a9b3 commit a0bb468

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

emcc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1289,8 +1289,8 @@ try:
12891289
fastcomp_opts += ['-pnacl-abi-simplify-preopt', '-pnacl-abi-simplify-postopt']
12901290
if shared.Settings.DISABLE_EXCEPTION_CATCHING != 1:
12911291
fastcomp_opts += ['-enable-emscripten-cxx-exceptions']
1292-
if len(shared.Settings.EXCEPTION_CATCHING_WHITELIST) > 0:
1293-
fastcomp_opts += ['-emscripten-cxx-exceptions-whitelist=' + ','.join(shared.Settings.EXCEPTION_CATCHING_WHITELIST)]
1292+
if shared.Settings.DISABLE_EXCEPTION_CATCHING == 2:
1293+
fastcomp_opts += ['-emscripten-cxx-exceptions-whitelist=' + ','.join(shared.Settings.EXCEPTION_CATCHING_WHITELIST or ['fake'])]
12941294

12951295
if shared.Settings.ASM_JS:
12961296
assert opt_level >= 1 or fastcomp, 'asm.js requires -O1 or above'

tests/core/test_exceptions_white_list_empty.out

Whitespace-only changes.

tests/test_core.py

+27
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,33 @@ def test_exceptions_white_list(self):
13471347
test_path = path_from_root('tests', 'core', 'test_exceptions_white_list')
13481348
src, output = (test_path + s for s in ('.in', '.out'))
13491349
self.do_run_from_file(src, output)
1350+
size = len(open('src.cpp.o.js').read())
1351+
shutil.copyfile('src.cpp.o.js', 'orig.js')
1352+
1353+
if os.environ.get('EMCC_FAST_COMPILER') != '0':
1354+
# check that an empty whitelist works properly (as in, same as exceptions disabled)
1355+
empty_output = path_from_root('tests', 'core', 'test_exceptions_white_list_empty.out')
1356+
1357+
Settings.EXCEPTION_CATCHING_WHITELIST = []
1358+
self.do_run_from_file(src, empty_output)
1359+
empty_size = len(open('src.cpp.o.js').read())
1360+
shutil.copyfile('src.cpp.o.js', 'empty.js')
1361+
1362+
Settings.EXCEPTION_CATCHING_WHITELIST = ['fake']
1363+
self.do_run_from_file(src, empty_output)
1364+
fake_size = len(open('src.cpp.o.js').read())
1365+
shutil.copyfile('src.cpp.o.js', 'fake.js')
1366+
1367+
Settings.DISABLE_EXCEPTION_CATCHING = 1
1368+
self.do_run_from_file(src, empty_output)
1369+
disabled_size = len(open('src.cpp.o.js').read())
1370+
shutil.copyfile('src.cpp.o.js', 'disabled.js')
1371+
1372+
assert size - empty_size > 2000, [empty_size, size] # big change when we disable entirely
1373+
assert size - fake_size > 2000, [fake_size, size]
1374+
assert empty_size == fake_size, [empty_size, fake_size]
1375+
assert empty_size - disabled_size < 100, [empty_size, disabled_size] # full disable removes a tiny bit more
1376+
assert fake_size - disabled_size < 100, [disabled_size, fake_size]
13501377

13511378
def test_exceptions_white_list_2(self):
13521379
Settings.DISABLE_EXCEPTION_CATCHING = 2

0 commit comments

Comments
 (0)