diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-03-01 11:51:05 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-03-01 13:31:43 -0800 |
commit | 0f23cac48fe4e5278e5b35f6a40e6f8a214d5e7c (patch) | |
tree | f040a29744747b63ec7a1dda13ceaebe74ea50b3 | |
parent | cde8796577b2d1959b5322172bec85ba6b10647c (diff) |
improve assertions message on function pointer errors
-rwxr-xr-x | emscripten.py | 6 | ||||
-rw-r--r-- | tests/test_other.py | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/emscripten.py b/emscripten.py index cb9eefab..eeb53bf7 100755 --- a/emscripten.py +++ b/emscripten.py @@ -1010,7 +1010,11 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, if other != sig: extra += other + ': " + debug_table_' + other + '[x] + " ' extra += '"); ' - asm_setup += '\nfunction nullFunc_' + sig + '(x) { Module["printErr"]("Invalid function pointer' + pointer + 'called with signature \'' + sig + '\'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an different type, which will fail?"); ' + extra + ' abort(x) }\n' + asm_setup += '\nfunction nullFunc_' + sig + '(x) { Module["printErr"]("Invalid function pointer' + pointer + 'called with signature \'' + sig + '\'. ' + \ + 'Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? ' + \ + 'Or calling a function with an incorrect type, which will fail? ' + \ + '(it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this) ' + \ + '"); ' + extra + ' abort(x) }\n' basic_vars = ['STACKTOP', 'STACK_MAX', 'tempDoublePtr', 'ABORT'] basic_float_vars = ['NaN', 'Infinity'] diff --git a/tests/test_other.py b/tests/test_other.py index 8b507306..678fa90d 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -556,10 +556,10 @@ f.close() else: # fastcomp. all asm, so it can't just work with wrong sigs. but, ASSERTIONS=2 gives much better info to debug test(['-O1'], 'abort') # no useful info - test(['-O1', '-s', 'ASSERTIONS=1'], '''Invalid function pointer called with signature 'v'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an different type, which will fail? + test(['-O1', '-s', 'ASSERTIONS=1'], '''Invalid function pointer called with signature 'v'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this) Build with ASSERTIONS=2 for more info. ''') # some useful text - test(['-O1', '-s', 'ASSERTIONS=2'], '''Invalid function pointer '1' called with signature 'v'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an different type, which will fail? + test(['-O1', '-s', 'ASSERTIONS=2'], '''Invalid function pointer '1' called with signature 'v'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this) This pointer might make sense in another type signature: i: _my_func ''') # actually useful identity of the bad pointer, with comparisons to what it would be in other types/tables |