diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-09-09 20:00:52 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-09-09 20:00:52 -0700 |
commit | 1896c00715d1cbfd47a295c9564691dcf88d6032 (patch) | |
tree | d2cc60a400f2b1878b63ae3773bd605701e36676 /src | |
parent | 953ebf768763fe93a0af76f5007d1f69f91d6440 (diff) |
check for segfaults in SAFE_HEAP
Diffstat (limited to 'src')
-rw-r--r-- | src/preamble.js | 4 | ||||
-rw-r--r-- | src/settings.js | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/preamble.js b/src/preamble.js index a8f19d64..bbb9d684 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -24,6 +24,8 @@ var ACCEPTABLE_SAFE_HEAP_ERRORS = 0; function SAFE_HEAP_ACCESS(dest, type, store, ignore) { //if (dest === A_NUMBER) Module.print ([dest, type, store] + ' ' + new Error().stack); // Something like this may be useful, in debugging + assert(dest >= STACK_ROOT, 'segmentation fault: null pointer, or below normal memory'); + #if USE_TYPED_ARRAYS // When using typed arrays, reads over the top of TOTAL_MEMORY will fail silently, so we must // correct that by growing TOTAL_MEMORY as needed. Without typed arrays, memory is a normal @@ -643,7 +645,7 @@ var base = intArrayFromString('(null)'); // So printing %s of NULL gives '(null) // Also this ensures we leave 0 as an invalid address, 'NULL' STATICTOP = base.length; for (var i = 0; i < base.length; i++) { - {{{ makeSetValue(0, 'i', 'base[i]', 'i8') }}} + {{{ makeSetValue(0, 'i', 'base[i]', 'i8', null, null, null, 1) }}} } Module['HEAP'] = HEAP; diff --git a/src/settings.js b/src/settings.js index 9f63622d..fe532bda 100644 --- a/src/settings.js +++ b/src/settings.js @@ -104,7 +104,9 @@ var CATCH_EXIT_CODE = 0; // If set, causes exit() to throw an exception object w // terminated with an error message. // Generated code debugging options -var SAFE_HEAP = 0; // Check each write to the heap against a list of blocked addresses +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 |