Skip to content
Open
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
8 changes: 7 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,13 @@ jobs:

- run:
name: Run tests
command: cd GDevelop.js && npm run test -- --maxWorkers=4
# Tests are slow under ASan and jest (in a non-TTY environment) only prints
# output when a whole test file finishes, so allow long silences instead of
# killing the step after the default 10 minutes without output.
no_output_timeout: 30m

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could actually be reduced back now :)

# malloc_context_size: record fewer stack frames on each malloc/free (default
# is 30) - a small, free speedup that only shortens traces in ASan reports.
command: cd GDevelop.js && ASAN_OPTIONS=malloc_context_size=5 npm run test -- --maxWorkers=4

# Upload artifacts (CircleCI)
- store_artifacts:
Expand Down
11 changes: 9 additions & 2 deletions GDevelop.js/Bindings/prejs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
// If running under ASAN, disable the "container overflow" checks because of false positives
// with std::vector<gd::String>. See https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow.
if (Module['ASAN_OPTIONS'] === undefined)
Module['ASAN_OPTIONS'] ='detect_container_overflow=0';
// Also append options from the ASAN_OPTIONS environment variable when running in Node.js,
// as Emscripten only reads them from Module['ASAN_OPTIONS'] (not from the environment).
if (Module['ASAN_OPTIONS'] === undefined) {
var envAsanOptions =
typeof process !== 'undefined' && process.env && process.env.ASAN_OPTIONS
? ':' + process.env.ASAN_OPTIONS
: '';
Module['ASAN_OPTIONS'] = 'detect_container_overflow=0' + envAsanOptions;
}

// Prevent calling process["exit"] when there is a abort/runtime crash
// (useful for tests when running ASAN, to see the logs).
Expand Down
4 changes: 3 additions & 1 deletion GDevelop.js/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ elseif("${GDEVELOPJS_BUILD_VARIANT}" STREQUAL "debug-assertions")
# Debug with assertions: no optimization.
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g --profiling") # Debugging + profiling support
elseif("${GDEVELOPJS_BUILD_VARIANT}" STREQUAL "debug-sanitizers")
# Debug with sanitizers: no optimization.
# Debug with sanitizers (note: -O3 from the Release build type still applies at compile time).
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g --profiling") # Debugging + profiling support
add_compile_options(-fsanitize=address) # Uncomment to auto-detect occurences of memory bugs (memory leak, use after free, overflows, ...) - also enable linking below!
# add_compile_options(-fsanitize=undefined) # Uncomment to auto-detect occurences of undefined behavior - also enable linking below!
Expand Down Expand Up @@ -111,6 +111,8 @@ elseif("${GDEVELOPJS_BUILD_VARIANT}" STREQUAL "debug-assertions")
# target_link_libraries(--memoryprofiler) # Uncomment for interactive memory profiling
elseif("${GDEVELOPJS_BUILD_VARIANT}" STREQUAL "debug-sanitizers")
message(STATUS "'debug-sanitizers' variant: enabling ASAN and other sanitizers")
target_link_libraries(GD "-O1") # Some optimization at link time (default is -O0), to make the tests run a bit faster in CI.
target_link_libraries(GD "-s INITIAL_MEMORY=512MB") # Start with a large heap: ASan needs a lot of memory (256MB quarantine for freed allocations, shadow memory) and growing the memory repeatedly has a cost. Overrides TOTAL_MEMORY set above.
target_link_libraries(GD "-fsanitize=address") # Uncomment to auto-detect occurences of memory bugs (memory leak, use after free, overflows, ...) - also enable compiling above!
# target_link_libraries(GD "-fsanitize=undefined") # Uncomment to auto-detect occurences of undefined behavior - also enable compiling above!
target_link_libraries(GD "-fsanitize=null") # Uncomment to auto-detect occurences of undefined behavior - also enable compiling above!
Expand Down
3 changes: 2 additions & 1 deletion GDevelop.js/__tests__/Serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ describe('libGD.js object serialization', function () {
']';

const element = gd.Serializer.fromJSON(json);
// Do NOT delete element, it's a static value.

// Round-trips back to the same JSON (also proves the large input was
// parsed correctly, not just that it didn't crash).
expect(gd.Serializer.toJSON(element)).toBe(json);
element.delete();
});
});

Expand Down
Loading
Loading