Skip to content
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

add automated asan testing during CI #284

Merged
merged 7 commits into from
Oct 3, 2024
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
22 changes: 21 additions & 1 deletion .github/workflows/test-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ jobs:
node-version: 18.x
- run: npm install --ignore-scripts
- run: npx node-pre-gyp configure --debug --enable_coverage
- run: npx node-pre-gyp build
- run: npx node-pre-gyp build -j max
- run: python3 -m pip install --upgrade pip
- run: pip3 install -r test/requirements.txt
- run: npx c8 npm test
Expand All @@ -229,3 +229,23 @@ jobs:
directory: ${{ github.workspace }}/coverage
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true


asan:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x
- run: npm install --ignore-scripts
- run: npx @mapbox/node-pre-gyp configure --debug --enable_asan
- run: npx @mapbox/node-pre-gyp build -j max
- run: python3 -m pip install --upgrade pip
- run: pip3 install -r test/requirements.txt
- run: npm test -- --repeats 10
env:
LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libasan.so.6
LSAN_OPTIONS: suppressions=${{ github.workspace }}/test/napi-leaks-suppression.txt
8 changes: 6 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@
"runtimeArgs": [
"--expose-gc",
],
"program": "${workspaceFolder}/node_modules/mocha/lib/cli/cli.js"
"program": "${workspaceFolder}/node_modules/mocha/lib/cli/cli.js",
"args": [
"--timeout",
"0"
]
},
{
"name": "Launch benchmarks (gdb)",
Expand Down Expand Up @@ -128,4 +132,4 @@
"program": "${file}"
}
]
}
}
152 changes: 104 additions & 48 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"eslint-plugin-array-func": "^5.0.1",
"eslint-plugin-mocha": "^10.4.1",
"eslint-plugin-prefer-arrow": "^1.2.3",
"mocha": "^10.1.0",
"mocha": "github:mmomtchev/mocha#mmom",
"node-gyp": "^10.0.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.1.2",
Expand Down
37 changes: 37 additions & 0 deletions test/napi-leaks-suppression.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# All leaks listed here are non-repeat offenders
# (ie they happen only a fixed number of times per process execution)
# The list is maintained for Node.js 18

# Ignore Python which does not have symbols
# Alas, this also covers up all stale Python references
leak:libpython3
leak:site-packages

# Known leaks in Node-API
leak:napi_module_register
leak:napi_register_module_v1

# Known leaks in the Node.js runtime
leak:node::builtins::BuiltinLoader::LoadBuiltinSource
leak:ProcessWrap::OnExit
leak:StringBytes::Encode
leak:Realm::ExecuteBootstrapper

# Known leaks in V8
leak:Heap_GenerationalBarrierSlow
leak:Scavenger::ScavengePage
leak:Scavenger::Process
leak:CompactionSpace::Expand
leak:Heap::IterateRoots
leak:Heap::PerformGarbageCollection
leak:Heap::InsertIntoRememberedSetFromCode
leak:Heap::SetUpSpaces
leak:Heap::PerformGarbageCollection
leak:PagedSpace::RefillLabMain
leak:OldLargeObjectSpace::AllocateRaw
leak:BaselineBatchCompiler::EnqueueFunction
leak:Compiler::FinalizeTurbofanCompilationJob
leak:v8::internal::Factory::CodeBuilder::Build
leak:v8::internal::MemoryChunk::RegisterObjectWithInvalidatedSlots
leak:v8::ScriptCompiler
leak:v8::internal::Genesis::Genesis
18 changes: 13 additions & 5 deletions test/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,11 +746,19 @@ describe('types', () => {
assert.isTrue(fn.callable);
assert.equal(fn.type, 'pymport.js_function');

const py_catch = pymport('python_helpers').get('dont_catch_exception');

assert.throws(() => {
py_catch.call(fn);
}, /Python exception: JS exception/);
const py_dont_catch = pymport('python_helpers').get('dont_catch_exception');

// V8 seems to have a problem with garbage collecting functions
// referenced in closures
// https://github.com/mmomtchev/pymport/issues/283
let failed = false;
try {
py_dont_catch.call(fn);
} catch (e: any) {
assert.match(e.toString(), /Python exception: JS exception/);
failed = true;
}
assert.isTrue(failed);
});

it('unsupported arguments', () => {
Expand Down
Loading