Skip to content

Commit 75d65a0

Browse files
committed
ci, checker, pref: extract .github/workflows/run_sanitizers.sh to ease local testing with different options
1 parent 0117c7f commit 75d65a0

File tree

6 files changed

+39
-12
lines changed

6 files changed

+39
-12
lines changed

.github/workflows/linux_ci.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,7 @@ jobs:
244244
- name: Valgrind
245245
run: valgrind --error-exitcode=1 v -o v.c cmd/v
246246
- name: Run sanitizers
247-
run: |
248-
v -o v2 cmd/v -cflags -fsanitize=memory
249-
v -o v3 cmd/v -cflags -fsanitize=thread
250-
v -o v4 cmd/v -cflags -fsanitize=undefined
251-
v -o v5 cmd/v -cflags -fsanitize=address,pointer-compare,pointer-subtract
252-
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v
253-
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v3 -o v.c cmd/v
254-
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v4 -o v.c cmd/v
255-
ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v5 -o v.c cmd/v
247+
run: .github/workflows/run_sanitizers.sh
256248
- name: v self compilation
257249
run: v -o v2 cmd/v && ./v2 -o v3 cmd/v && ./v3 -o v4 cmd/v
258250
- name: v self compilation with -usecache

.github/workflows/run_sanitizers.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
export PS4='\033[0;33m+ >>>>> (${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }\033[0m'
4+
5+
set -xe
6+
7+
echo " Setup environment ..."
8+
export DEBUG_OPTS=${DEBUG_OPTS:-"-keepc -cg -cflags -fno-omit-frame-pointer"}
9+
export VFLAGS=${VFLAGS:-"-cc clang"}
10+
v version
11+
v -show-c-output -cflags --version -e ';' || true
12+
13+
echo " Compile and run sanitizers ..."
14+
15+
v ${VFLAGS} ${DEBUG_OPTS} -o v2 cmd/v -cflags -fsanitize=memory
16+
UBSAN_OPTIONS="print_stacktrace=1:halt_on_error=1" ./v2 -o v.c cmd/v
17+
18+
v ${VFLAGS} ${DEBUG_OPTS} -o v3 cmd/v -cflags -fsanitize=thread
19+
TSAN_OPTIONS="suppressions=.github/workflows/run_sanitizers_thread.suppressions" UBSAN_OPTIONS="print_stacktrace=1:halt_on_error=1" ./v3 -o v.c cmd/v
20+
21+
v ${VFLAGS} ${DEBUG_OPTS} -o v4 cmd/v -cflags -fsanitize=undefined
22+
UBSAN_OPTIONS="suppressions=.github/workflows/run_sanitizers_undefined.suppressions:print_stacktrace=1:halt_on_error=1" ./v4 -o v.c cmd/v
23+
24+
v ${VFLAGS} ${DEBUG_OPTS} -o v5 cmd/v -cflags -fsanitize=address,pointer-compare,pointer-subtract
25+
ASAN_OPTIONS="detect_leaks=0" UBSAN_OPTIONS="print_stacktrace=1:halt_on_error=1" ./v5 -o v.c cmd/v
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## See https://github.com/google/sanitizers/wiki/ThreadSanitizerSuppressions
2+
## and https://clang.llvm.org/docs/ThreadSanitizer.html
3+
## The sync__stdatomic__add_i64 and sync__stdatomic__sub_i64 suppressions below, are needed for clang-10 to clang-12; clang-18 is fine without them
4+
race:sync__stdatomic__add_i64
5+
race:sync__stdatomic__sub_i64
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## See https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
2+
function:rand__internal_ulid_at_millisecond
3+
function:sync__pool__process_in_thread
4+
function:rand__deinit

vlib/v/checker/fn.v

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,8 +2111,9 @@ fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type {
21112111
has_method = true
21122112
mut embed_types := []ast.Type{}
21132113
method, embed_types = c.table.find_method_from_embeds(final_left_sym, method_name) or {
2114-
if err.msg() != '' {
2115-
c.error(err.msg(), node.pos)
2114+
emsg := err.str()
2115+
if emsg != '' {
2116+
c.error(emsg, node.pos)
21162117
}
21172118
has_method = false
21182119
ast.Fn{}, []ast.Type{}

vlib/v/pref/pref.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ fn run_code_in_tmp_vfile_and_exit(args []string, mut res Preferences, option_nam
285285
panic('Failed to create temporary file ${tmp_v_file_path}')
286286
}
287287
run_options := cmdline.options_before(args, [option_name]).join(' ')
288-
command_options := cmdline.options_after(args, [option_name])[1..].join(' ')
288+
command_options := cmdline.options_after(args, [option_name])#[1..].join(' ')
289289
vexe := vexe_path()
290290
tmp_cmd := '${os.quoted_path(vexe)} ${output_option} ${run_options} run ${os.quoted_path(tmp_v_file_path)} ${command_options}'
291291

0 commit comments

Comments
 (0)