diff options
-rwxr-xr-x | emscripten.py | 7 | ||||
-rwxr-xr-x | tests/runner.py | 7 |
2 files changed, 11 insertions, 3 deletions
diff --git a/emscripten.py b/emscripten.py index 91dbe8ff..62f68fcd 100755 --- a/emscripten.py +++ b/emscripten.py @@ -389,7 +389,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, newline = '\n' in item return (bad if item.replace('\n', '') == '0' else item) + ('\n' if newline else '') body = ','.join(map(fix_item, body)) - return ('function %s(%s) { %s abort(%d); %s }' % (bad, params, coercions, i, ret), raw[:start+1] + body + raw[end:]) + return ('function %s(%s) { %s %s(%d); %s }' % (bad, params, coercions, 'abort' if not settings['ASSERTIONS'] else 'nullFunc', i, ret), raw[:start+1] + body + raw[end:]) infos = [make_table(sig, raw) for sig, raw in last_forwarded_json['Functions']['tables'].iteritems()] function_tables_defs = '\n'.join([info[0] for info in infos]) + '\n// EMSCRIPTEN_END_FUNCS\n' + '\n'.join([info[1] for info in infos]) @@ -398,10 +398,15 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, fundamentals = ['Math', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint16Array', 'Uint32Array', 'Float32Array', 'Float64Array'] math_envs = ['Math.min'] # TODO: move min to maths asm_setup += '\n'.join(['var %s = %s;' % (f.replace('.', '_'), f) for f in math_envs]) + basic_funcs = ['abort', 'assert', 'asmPrintInt', 'asmPrintFloat', 'copyTempDouble', 'copyTempFloat'] + [m.replace('.', '_') for m in math_envs] if settings['RESERVED_FUNCTION_POINTERS'] > 0: basic_funcs.append('jsCall') if settings['SAFE_HEAP']: basic_funcs += ['SAFE_HEAP_LOAD', 'SAFE_HEAP_STORE', 'SAFE_HEAP_CLEAR'] if settings['CHECK_HEAP_ALIGN']: basic_funcs += ['CHECK_ALIGN_2', 'CHECK_ALIGN_4', 'CHECK_ALIGN_8'] + if settings['ASSERTIONS']: + basic_funcs += ['nullFunc'] + asm_setup += 'function nullFunc(x) { Module["printErr"]("Invalid function pointer called. Perhaps a miscast function pointer (check compilation warnings) or bad vtable lookup (maybe due to derefing a bad pointer, like NULL)?"); abort(x) }\n' + basic_vars = ['STACKTOP', 'STACK_MAX', 'tempDoublePtr', 'ABORT'] basic_float_vars = ['NaN', 'Infinity'] diff --git a/tests/runner.py b/tests/runner.py index 860fe8ae..8168f332 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -9619,13 +9619,16 @@ f.close() def test(args, expected, err_expected=None): out, err = Popen([PYTHON, EMCC, 'src.c'] + args, stderr=PIPE).communicate() if err_expected: self.assertContained(err_expected, err) - self.assertContained(expected, run_js(self.in_dir('a.out.js'), stderr=PIPE)) + self.assertContained(expected, run_js(self.in_dir('a.out.js'), stderr=PIPE, full_output=True)) return open(self.in_dir('a.out.js')).read() test([], 'my func') # no asm, so casting func works test(['-O2'], 'abort', ['Casting potentially incompatible function pointer i32 ()* to void (...)*, for my_func', 'Incompatible function pointer casts are very dangerous with ASM_JS=1, you should investigate and correct these']) # asm, so failure - #test(['-O2', '-g'], 'abort') # asm -g gives better message, so failure + test(['-O2', '-s', 'ASSERTIONS=1'], + 'Invalid function pointer called. Perhaps a miscast function pointer (check compilation warnings) or bad vtable lookup (maybe due to derefing a bad pointer, like NULL)?', + ['Casting potentially incompatible function pointer i32 ()* to void (...)*, for my_func', + 'Incompatible function pointer casts are very dangerous with ASM_JS=1, you should investigate and correct these']) # asm, so failure def test_l_link(self): # Linking with -lLIBNAME and -L/DIRNAME should work |