diff --git a/emcc b/emcc index eef18110e..1b0d214b8 100755 --- a/emcc +++ b/emcc @@ -895,6 +895,7 @@ try: try: assert shared.Settings.ASM_JS > 0, 'ASM_JS must be enabled in fastcomp' + assert shared.Settings.SAFE_HEAP in [0, 1], 'safe heap must be 0 or 1 in fastcomp' assert shared.Settings.UNALIGNED_MEMORY == 0, 'forced unaligned memory not supported in fastcomp' assert shared.Settings.FORCE_ALIGNED_MEMORY == 0, 'forced aligned memory is not supported in fastcomp' assert shared.Settings.SAFE_DYNCALLS == 0, 'safe dyncalls not supported in fastcomp' @@ -935,9 +936,6 @@ try: js_opts = True logging.warning('enabling js opts for SAFE_HEAP') - if shared.Settings.SAFE_HEAP >= 2: - debug_level = 4 # must keep debug info to do line-by-line operations - if debug_level > 1 and closure: logging.warning('disabling closure because debug info was requested') closure = False diff --git a/site/source/docs/porting/Debugging.rst b/site/source/docs/porting/Debugging.rst index c59c55ded..31f3c22ab 100644 --- a/site/source/docs/porting/Debugging.rst +++ b/site/source/docs/porting/Debugging.rst @@ -80,9 +80,9 @@ The most important settings are: - .. _debugging-SAFE-HEAP: - - ``SAFE_HEAP=1`` adds additional memory access checks, and will give clear errors for problems like dereferencing 0 and memory alignment issues. Use ``SAFE_HEAP=2`` in order to check only specific lines listed in ``SAFE_HEAP_LINES``, and use ``SAFE_HEAP=3`` to check all the lines except those specified. This last option is the most common operation. - + + ``SAFE_HEAP=1`` adds additional memory access checks, and will give clear errors for problems like dereferencing 0 and memory alignment issues. + You can also set ``SAFE_HEAP_LOG`` to log ``SAFE_HEAP`` operations. A number of other useful debug settings are defined in `src/settings.js `_. For more information, search that file for the keywords "check" and "debug". diff --git a/src/compiler.js b/src/compiler.js index a53712619..304ff8a70 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -151,10 +151,6 @@ if (settings_file) { } -if (SAFE_HEAP >= 2) { - SAFE_HEAP_LINES = set(SAFE_HEAP_LINES); // for fast checking -} - EXPORTED_FUNCTIONS = set(EXPORTED_FUNCTIONS); EXPORTED_GLOBALS = set(EXPORTED_GLOBALS); EXCEPTION_CATCHING_WHITELIST = set(EXCEPTION_CATCHING_WHITELIST); diff --git a/src/parseTools.js b/src/parseTools.js index 5f154f73b..233437293 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -707,13 +707,8 @@ function indentify(text, indent) { // Correction tools -function checkSpecificSafeHeap() { - if (!Framework.currItem) return false; - return (SAFE_HEAP === 2 && Debugging.getIdentifier() in SAFE_HEAP_LINES) || - (SAFE_HEAP === 3 && !(Debugging.getIdentifier() in SAFE_HEAP_LINES)); -} function checkSafeHeap() { - return SAFE_HEAP === 1 || checkSpecificSafeHeap(); + return SAFE_HEAP === 1; } function getHeapOffset(offset, type) { diff --git a/src/settings.js b/src/settings.js index 0d5a74c45..314d24a34 100644 --- a/src/settings.js +++ b/src/settings.js @@ -164,10 +164,6 @@ var SIMPLIFY_IFS = 1; // Whether to simplify ifs in js-optimizer.js var SAFE_HEAP = 0; // Check each write to the heap, for example, this will give a clear // error on what would be segfaults in a native build (like deferencing // 0). See preamble.js for the actual checks performed. - // If equal to 2, done on a line-by-line basis according to - // SAFE_HEAP_LINES, checking only the specified lines. - // If equal to 3, checking all *but* the specified lines. Note - // that 3 is the option you usually want here. var SAFE_HEAP_LOG = 0; // Log out all SAFE_HEAP operations var SAFE_DYNCALLS = 0; // Show stack traces on missing function pointer/virtual method calls @@ -562,7 +558,6 @@ var DEBUG_TAGS_SHOWING = []; // For internal use only var ORIGINAL_EXPORTED_FUNCTIONS = []; -var SAFE_HEAP_LINES = []; // The list of defines (C_DEFINES) was moved into struct_info.json in the same directory. // That file is automatically parsed by tools/gen_struct_info.py. diff --git a/tests/test_core.py b/tests/test_core.py index 38215bdd8..fc7b82f06 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -2728,11 +2728,6 @@ The current type of b is: 9 self.do_run_from_file(src, output) def test_statics(self): - # static initializers save i16 but load i8 for some reason (or i64 and load i8) - if Settings.SAFE_HEAP: - Settings.SAFE_HEAP = 3 - Settings.SAFE_HEAP_LINES = ['src.cpp:19', 'src.cpp:26', 'src.cpp:28'] - test_path = path_from_root('tests', 'core', 'test_statics') src, output = (test_path + s for s in ('.in', '.out')) @@ -5291,13 +5286,6 @@ def process(filename): def test_the_bullet(self): # Called thus so it runs late in the alphabetical cycle... it is long Settings.DEAD_FUNCTIONS = ['__ZSt9terminatev'] - # Note: this is also a good test of per-file and per-line changes (since we have multiple files, and correct specific lines) - if Settings.SAFE_HEAP: - # Ignore bitfield warnings - Settings.SAFE_HEAP = 3 - Settings.SAFE_HEAP_LINES = ['btVoronoiSimplexSolver.h:40', 'btVoronoiSimplexSolver.h:41', - 'btVoronoiSimplexSolver.h:42', 'btVoronoiSimplexSolver.h:43'] - asserts = Settings.ASSERTIONS for use_cmake in [False, True]: # If false, use a configure script to configure Bullet build. @@ -6461,30 +6449,6 @@ def process(filename): # This test *should* fail, by throwing this exception assert 'Assertion failed: Load-store consistency assumption failure!' in str(e), str(e) - # And we should not fail if we disable checking on that line - - Settings.SAFE_HEAP = 3 - Settings.SAFE_HEAP_LINES = ["src.cpp:7"] - - self.do_run(src, '*ok*') - - # But if we disable the wrong lines, we still fail - - Settings.SAFE_HEAP_LINES = ["src.cpp:99"] - - try: - self.do_run(src, '*nothingatall*', assert_returncode=None) - except Exception, e: - # This test *should* fail, by throwing this exception - assert 'Assertion failed: Load-store consistency assumption failure!' in str(e), str(e) - - # And reverse the checks with = 2 - - Settings.SAFE_HEAP = 2 - Settings.SAFE_HEAP_LINES = ["src.cpp:99"] - - self.do_run(src, '*ok*') - Settings.SAFE_HEAP = 1 # Linking multiple files should work too @@ -6528,23 +6492,6 @@ def process(filename): # This test *should* fail, by throwing this exception assert 'Assertion failed: Load-store consistency assumption failure!' in str(e), str(e) - # And we should not fail if we disable checking on those lines - - Settings.SAFE_HEAP = 3 - Settings.SAFE_HEAP_LINES = ["module.cpp:7", "main.cpp:9"] - - self.do_ll_run(all_name, '*ok*') - - # But we will fail if we do not disable exactly what we need to - any mistake leads to error - - for lines in [["module.cpp:22", "main.cpp:9"], ["module.cpp:7", "main.cpp:29"], ["module.cpp:127", "main.cpp:449"], ["module.cpp:7"], ["main.cpp:9"]]: - Settings.SAFE_HEAP_LINES = lines - try: - self.do_ll_run(all_name, '*nothingatall*', assert_returncode=None) - except Exception, e: - # This test *should* fail, by throwing this exception - assert 'Assertion failed: Load-store consistency assumption failure!' in str(e), str(e) - def test_source_map(self): if self.is_emterpreter(): return self.skip('todo') if NODE_JS not in JS_ENGINES: return self.skip('sourcemapper requires Node to run')