Skip to content

Fix wasm2s (SAFE_HEAP) test suite #15944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/preamble_minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "runtime_safe_heap.js"

#if ASSERTIONS
#if ASSERTIONS || SAFE_HEAP
/** @type {function(*, string=)} */
function assert(condition, text) {
if (!condition) throw text;
Expand Down
4 changes: 2 additions & 2 deletions src/runtime_safe_heap.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function SAFE_HEAP_STORE(dest, value, bytes, isFloat) {
#else
if (dest % bytes !== 0) warnOnce('alignment error in a memory store operation, alignment was a multiple of ' + (((dest ^ (dest-1)) >> 1) + 1) + ', but was was expected to be aligned to a multiple of ' + bytes);
#endif
if (runtimeInitialized) {
if (runtimeInitialized && !runtimeExited) {
var brk = _sbrk() >>> 0;
if (dest + bytes > brk) abort('segmentation fault, exceeded the top of the available dynamic heap when storing ' + bytes + ' bytes to address ' + dest + '. DYNAMICTOP=' + brk);
assert(brk >= _emscripten_stack_get_base()); // sbrk-managed memory must be above the stack
Expand All @@ -134,7 +134,7 @@ function SAFE_HEAP_LOAD(dest, bytes, unsigned, isFloat) {
#else
if (dest % bytes !== 0) warnOnce('alignment error in a memory load operation, alignment was a multiple of ' + (((dest ^ (dest-1)) >> 1) + 1) + ', but was was expected to be aligned to a multiple of ' + bytes);
#endif
if (runtimeInitialized) {
if (runtimeInitialized && !runtimeExited) {
var brk = _sbrk() >>> 0;
if (dest + bytes > brk) abort('segmentation fault, exceeded the top of the available dynamic heap when loading ' + bytes + ' bytes from address ' + dest + '. DYNAMICTOP=' + brk);
assert(brk >= _emscripten_stack_get_base()); // sbrk-managed memory must be above the stack
Expand Down
2 changes: 2 additions & 0 deletions src/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,9 @@ assert(typeof Module['TOTAL_MEMORY'] === 'undefined', 'Module.TOTAL_MEMORY has b
{{{ makeRemovedFSAssert('IDBFS') }}}
{{{ makeRemovedFSAssert('PROXYFS') }}}
{{{ makeRemovedFSAssert('WORKERFS') }}}
#if !NODERAWFS
{{{ makeRemovedFSAssert('NODEFS') }}}
#endif
{{{ makeRemovedRuntimeFunction('alignMemory') }}}

#if USE_PTHREADS
Expand Down
4 changes: 2 additions & 2 deletions tests/core/test_functionpointer_libfunc_varargs.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ typedef int (*fp_t)(int, int, ...);
int main(int argc, char **argv) {
fp_t fp = &fcntl;
if (argc == 1337) fp = (fp_t) & main;
(*fp)(0, 10);
(*fp)(0, 10, 5);
(*fp)(0, F_GETFL);
(*fp)(0, F_SETSIG, 5);
printf("waka\n");
return 0;
}
14 changes: 7 additions & 7 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7881,13 +7881,11 @@ def test_memprof_requirements(self):
# This test checks for the global variables required to run the memory
# profiler. It would fail if these variables were made no longer global
# or if their identifiers were changed.
create_file('main.cpp', '''
extern "C" {
void check_memprof_requirements();
}
create_file('main.c', '''
int check_memprof_requirements();

int main() {
check_memprof_requirements();
return 0;
return check_memprof_requirements();
}
''')
create_file('lib.js', '''
Expand All @@ -7898,14 +7896,16 @@ def test_memprof_requirements(self):
typeof _emscripten_stack_get_current === 'function' &&
typeof Module['___heap_base'] === 'number') {
out('able to run memprof');
return 0;
} else {
out('missing the required variables to run memprof');
return 1;
}
}
});
''')
self.emcc_args += ['--memoryprofiler', '--js-library', 'lib.js']
self.do_runf('main.cpp', 'able to run memprof')
self.do_runf('main.c', 'able to run memprof')

def test_fs_dict(self):
self.set_setting('FORCE_FILESYSTEM')
Expand Down