Skip to content

Commit 5710dcf

Browse files
committed
build: add test-ubsan ci
Signed-off-by: RafaelGSS <[email protected]>
1 parent 27c5124 commit 5710dcf

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

.github/workflows/test-ubsan.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Test UBSan
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
paths-ignore:
7+
- .mailmap
8+
- '**.md'
9+
- AUTHORS
10+
- doc/**
11+
- .github/**
12+
- '!.github/workflows/ubsan-asan.yml'
13+
push:
14+
branches:
15+
- main
16+
- canary
17+
- v[0-9]+.x-staging
18+
- v[0-9]+.x
19+
paths-ignore:
20+
- .mailmap
21+
- '**.md'
22+
- AUTHORS
23+
- doc/**
24+
- .github/**
25+
- '!.github/workflows/ubsan-asan.yml'
26+
27+
concurrency:
28+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
29+
cancel-in-progress: true
30+
31+
env:
32+
ASAN_OPTIONS: intercept_tls_get_addr=0
33+
PYTHON_VERSION: '3.11'
34+
FLAKY_TESTS: keep_retrying
35+
36+
permissions:
37+
contents: read
38+
39+
jobs:
40+
test-ubsan:
41+
if: github.event.pull_request.draft == false
42+
runs-on: ubuntu-20.04
43+
env:
44+
CC: clang
45+
CXX: clang++
46+
LINK: clang++
47+
CONFIG_FLAGS: --enable-ubsan
48+
steps:
49+
- uses: actions/checkout@v3
50+
with:
51+
persist-credentials: false
52+
- name: Set up Python ${{ env.PYTHON_VERSION }}
53+
uses: actions/setup-python@v4
54+
with:
55+
python-version: ${{ env.PYTHON_VERSION }}
56+
- name: Environment Information
57+
run: npx envinfo
58+
- name: Build
59+
run: make build-ci -j2 V=1
60+
- name: Test
61+
run: make run-ci -j2 V=1 TEST_CI_ARGS="-p actions -t 300 --measure-flakiness 9"

common.gypi

+27
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
'variables': {
33
'configuring_node%': 0,
44
'asan%': 0,
5+
'ubsan%': 0,
56
'werror': '', # Turn off -Werror in V8 build.
67
'visibility%': 'hidden', # V8's visibility setting
78
'target_arch%': 'ia32', # set v8's target architecture
@@ -369,6 +370,32 @@
369370
}],
370371
],
371372
}],
373+
['ubsan == 1 and OS != "mac" and OS != "zos"', {
374+
'cflags+': [
375+
'-fno-omit-frame-pointer',
376+
'-fsanitize=undefined',
377+
],
378+
'defines': [ 'UNDEFINED_SANITIZER'],
379+
'cflags!': [ '-fomit-frame-pointer' ],
380+
'ldflags': [ '-fsanitize=undefined' ],
381+
}],
382+
['ubsan == 1 and OS == "mac"', {
383+
'xcode_settings': {
384+
'OTHER_CFLAGS+': [
385+
'-fno-omit-frame-pointer',
386+
'-fsanitize=undefined',
387+
'-DUNDEFINED_SANITIZER'
388+
],
389+
'OTHER_CFLAGS!': [
390+
'-fomit-frame-pointer',
391+
],
392+
},
393+
'target_conditions': [
394+
['_type!="static_library"', {
395+
'xcode_settings': {'OTHER_LDFLAGS': ['-fsanitize=undefined']},
396+
}],
397+
],
398+
}],
372399
['v8_enable_pointer_compression == 1', {
373400
'defines': [
374401
'V8_COMPRESS_POINTERS',

configure.py

+7
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,12 @@
710710
default=None,
711711
help='compile for Address Sanitizer to find memory bugs')
712712

713+
parser.add_argument('--enable-ubsan',
714+
action='store_true',
715+
dest='enable_ubsan',
716+
default=None,
717+
help='compile for Undefined Behavior Sanitizer')
718+
713719
parser.add_argument('--enable-static',
714720
action='store_true',
715721
dest='enable_static',
@@ -1407,6 +1413,7 @@ def configure_node(o):
14071413
o['variables']['library_files'] = options.linked_module
14081414

14091415
o['variables']['asan'] = int(options.enable_asan or 0)
1416+
o['variables']['ubsan'] = int(options.enable_ubsan or 0)
14101417

14111418
if options.coverage:
14121419
o['variables']['coverage'] = 'true'

0 commit comments

Comments
 (0)