mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 05:25:19 +00:00
build,tools: add test-ubsan ci
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> Co-Authored-By: Santiago Gimeno <santiago.gimeno@gmail.com> PR-URL: https://github.com/nodejs/node/pull/46297 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com>
This commit is contained in:
parent
40ef2da8d6
commit
ba06c5c509
63
.github/workflows/test-ubsan.yml
vendored
Normal file
63
.github/workflows/test-ubsan.yml
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
name: Test UBSan
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened, ready_for_review]
|
||||||
|
paths-ignore:
|
||||||
|
- .mailmap
|
||||||
|
- '**.md'
|
||||||
|
- AUTHORS
|
||||||
|
- doc/**
|
||||||
|
- .github/**
|
||||||
|
- '!.github/workflows/ubsan-asan.yml'
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- canary
|
||||||
|
- v[0-9]+.x-staging
|
||||||
|
- v[0-9]+.x
|
||||||
|
paths-ignore:
|
||||||
|
- .mailmap
|
||||||
|
- '**.md'
|
||||||
|
- AUTHORS
|
||||||
|
- doc/**
|
||||||
|
- .github/**
|
||||||
|
- '!.github/workflows/ubsan-asan.yml'
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
PYTHON_VERSION: '3.11'
|
||||||
|
FLAKY_TESTS: keep_retrying
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-ubsan:
|
||||||
|
if: github.event.pull_request.draft == false
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
env:
|
||||||
|
CC: gcc
|
||||||
|
CXX: g++
|
||||||
|
LINK: g++
|
||||||
|
CONFIG_FLAGS: --enable-ubsan
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Store suppressions path
|
||||||
|
run: |
|
||||||
|
echo "UBSAN_OPTIONS=suppressions=$GITHUB_WORKSPACE/suppressions.supp" >> $GITHUB_ENV
|
||||||
|
- name: Set up Python ${{ env.PYTHON_VERSION }}
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.PYTHON_VERSION }}
|
||||||
|
- name: Environment Information
|
||||||
|
run: npx envinfo
|
||||||
|
- name: Build
|
||||||
|
run: make build-ci -j2 V=1
|
||||||
|
- name: Test
|
||||||
|
run: make run-ci -j2 V=1 TEST_CI_ARGS="-p actions -t 300 --measure-flakiness 9"
|
24
common.gypi
24
common.gypi
@ -2,6 +2,7 @@
|
|||||||
'variables': {
|
'variables': {
|
||||||
'configuring_node%': 0,
|
'configuring_node%': 0,
|
||||||
'asan%': 0,
|
'asan%': 0,
|
||||||
|
'ubsan%': 0,
|
||||||
'werror': '', # Turn off -Werror in V8 build.
|
'werror': '', # Turn off -Werror in V8 build.
|
||||||
'visibility%': 'hidden', # V8's visibility setting
|
'visibility%': 'hidden', # V8's visibility setting
|
||||||
'target_arch%': 'ia32', # set v8's target architecture
|
'target_arch%': 'ia32', # set v8's target architecture
|
||||||
@ -374,6 +375,29 @@
|
|||||||
}],
|
}],
|
||||||
],
|
],
|
||||||
}],
|
}],
|
||||||
|
['ubsan == 1 and OS != "mac" and OS != "zos"', {
|
||||||
|
'cflags+': [
|
||||||
|
'-fno-omit-frame-pointer',
|
||||||
|
'-fsanitize=undefined',
|
||||||
|
],
|
||||||
|
'defines': [ 'UNDEFINED_SANITIZER'],
|
||||||
|
'cflags!': [ '-fno-omit-frame-pointer' ],
|
||||||
|
'ldflags': [ '-fsanitize=undefined' ],
|
||||||
|
}],
|
||||||
|
['ubsan == 1 and OS == "mac"', {
|
||||||
|
'xcode_settings': {
|
||||||
|
'OTHER_CFLAGS+': [
|
||||||
|
'-fno-omit-frame-pointer',
|
||||||
|
'-fsanitize=undefined',
|
||||||
|
'-DUNDEFINED_SANITIZER'
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'target_conditions': [
|
||||||
|
['_type!="static_library"', {
|
||||||
|
'xcode_settings': {'OTHER_LDFLAGS': ['-fsanitize=undefined']},
|
||||||
|
}],
|
||||||
|
],
|
||||||
|
}],
|
||||||
# The defines bellow must include all things from the external_v8_defines
|
# The defines bellow must include all things from the external_v8_defines
|
||||||
# list in v8/BUILD.gn.
|
# list in v8/BUILD.gn.
|
||||||
['v8_enable_v8_checks == 1', {
|
['v8_enable_v8_checks == 1', {
|
||||||
|
@ -725,6 +725,12 @@ parser.add_argument('--enable-asan',
|
|||||||
default=None,
|
default=None,
|
||||||
help='compile for Address Sanitizer to find memory bugs')
|
help='compile for Address Sanitizer to find memory bugs')
|
||||||
|
|
||||||
|
parser.add_argument('--enable-ubsan',
|
||||||
|
action='store_true',
|
||||||
|
dest='enable_ubsan',
|
||||||
|
default=None,
|
||||||
|
help='compile for Undefined Behavior Sanitizer')
|
||||||
|
|
||||||
parser.add_argument('--enable-static',
|
parser.add_argument('--enable-static',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
dest='enable_static',
|
dest='enable_static',
|
||||||
@ -1440,6 +1446,7 @@ def configure_node(o):
|
|||||||
o['variables']['linked_module_files'] = options.linked_module
|
o['variables']['linked_module_files'] = options.linked_module
|
||||||
|
|
||||||
o['variables']['asan'] = int(options.enable_asan or 0)
|
o['variables']['asan'] = int(options.enable_asan or 0)
|
||||||
|
o['variables']['ubsan'] = int(options.enable_ubsan or 0)
|
||||||
|
|
||||||
if options.coverage:
|
if options.coverage:
|
||||||
o['variables']['coverage'] = 'true'
|
o['variables']['coverage'] = 'true'
|
||||||
|
@ -68,7 +68,7 @@ void SyncProcessOutputBuffer::OnRead(const uv_buf_t* buf, size_t nread) {
|
|||||||
|
|
||||||
|
|
||||||
size_t SyncProcessOutputBuffer::Copy(char* dest) const {
|
size_t SyncProcessOutputBuffer::Copy(char* dest) const {
|
||||||
memcpy(dest, data_, used());
|
if (dest != nullptr) memcpy(dest, data_, used());
|
||||||
return used();
|
return used();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
suppressions.supp
Normal file
6
suppressions.supp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
vptr:deps/icu-small/source/common/uloc_tag.cpp
|
||||||
|
vptr:deps/icu-small/source/common/unistr.cpp
|
||||||
|
shift-base:deps/v8/src/wasm/decoder.h
|
||||||
|
vptr:deps/icu-small/source/common/sharedobject.cpp
|
||||||
|
vptr:deps/icu-small/source/i18n/coll.cpp
|
||||||
|
nonnull-attribute:deps/v8/src/snapshot/snapshot-source-sink.h
|
@ -46,6 +46,10 @@ function skipIfSingleExecutableIsNotSupported() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.config.variables.ubsan) {
|
||||||
|
common.skip('UndefinedBehavior Sanitizer is not supported');
|
||||||
|
}
|
||||||
|
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
|
|
||||||
// The SEA tests involve making a copy of the executable and writing some fixtures
|
// The SEA tests involve making a copy of the executable and writing some fixtures
|
||||||
|
@ -31,7 +31,11 @@ describe('console output', { concurrency: true }, () => {
|
|||||||
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceStackTrace);
|
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceStackTrace);
|
||||||
for (const { name, transform, env } of tests) {
|
for (const { name, transform, env } of tests) {
|
||||||
it(name, async () => {
|
it(name, async () => {
|
||||||
await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { env });
|
await snapshot.spawnAndAssert(
|
||||||
|
fixtures.path(name),
|
||||||
|
transform ?? defaultTransform,
|
||||||
|
{ env: { ...env, ...process.env } },
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user