ci: fix sanitizers and add -fsanitize=undefined (#7306)
parent
9b139c58ca
commit
f57c7032b4
|
@ -156,6 +156,10 @@ jobs:
|
||||||
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
|
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
|
||||||
- name: Build V
|
- name: Build V
|
||||||
run: make -j4 && ./v -cg -cflags -Werror -o v cmd/v
|
run: make -j4 && ./v -cg -cflags -Werror -o v cmd/v
|
||||||
|
- name: Run sanitizers
|
||||||
|
run: |
|
||||||
|
./v -o v2 cmd/v -cflags -fsanitize=undefined
|
||||||
|
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v
|
||||||
- name: Build V using V
|
- name: Build V using V
|
||||||
run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v
|
run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v
|
||||||
- name: v self with -usecache
|
- name: v self with -usecache
|
||||||
|
@ -221,6 +225,12 @@ jobs:
|
||||||
run: make -j4 && ./v -cc gcc -cg -cflags -Werror -o v cmd/v
|
run: make -j4 && ./v -cc gcc -cg -cflags -Werror -o v cmd/v
|
||||||
- name: Valgrind
|
- name: Valgrind
|
||||||
run: valgrind --error-exitcode=1 ./v -o v.c cmd/v
|
run: valgrind --error-exitcode=1 ./v -o v.c cmd/v
|
||||||
|
- name: Run sanitizers
|
||||||
|
run: |
|
||||||
|
./v -o v2 cmd/v -cflags -fsanitize=thread
|
||||||
|
./v -o v3 cmd/v -cflags "-fsanitize=undefined -fno-sanitize=alignment"
|
||||||
|
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v
|
||||||
|
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v3 -o v.c cmd/v
|
||||||
# - name: Test V
|
# - name: Test V
|
||||||
# run: ./v -silent test-compiler
|
# run: ./v -silent test-compiler
|
||||||
# - name: Test v binaries
|
# - name: Test v binaries
|
||||||
|
@ -310,8 +320,12 @@ jobs:
|
||||||
run: valgrind --error-exitcode=1 ./v -o v.c cmd/v
|
run: valgrind --error-exitcode=1 ./v -o v.c cmd/v
|
||||||
- name: Run sanitizers
|
- name: Run sanitizers
|
||||||
run: |
|
run: |
|
||||||
./v -o v2 cmd/v -cflags -fsanitize=memory && ./v2 -o v.c cmd/v
|
./v -o v2 cmd/v -cflags -fsanitize=memory
|
||||||
./v -o v2 cmd/v -cflags -fsanitize=thread && ./v2 -o v.c cmd/v
|
./v -o v3 cmd/v -cflags -fsanitize=thread
|
||||||
|
./v -o v4 cmd/v -cflags -fsanitize=undefined
|
||||||
|
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v
|
||||||
|
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v3 -o v.c cmd/v
|
||||||
|
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v4 -o v.c cmd/v
|
||||||
- name: v self compilation
|
- name: v self compilation
|
||||||
run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v && ./v3 -o v4 cmd/v
|
run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v && ./v3 -o v4 cmd/v
|
||||||
- name: v self with -usecache
|
- name: v self with -usecache
|
||||||
|
|
|
@ -338,7 +338,9 @@ pub fn (a &array) clone() array {
|
||||||
unsafe {arr.set_unsafe(i, &ar_clone)}
|
unsafe {arr.set_unsafe(i, &ar_clone)}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unsafe {C.memcpy(byteptr(arr.data), a.data, a.cap * a.element_size)}
|
if !isnil(a.data) {
|
||||||
|
unsafe {C.memcpy(byteptr(arr.data), a.data, a.cap * a.element_size)}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return arr
|
return arr
|
||||||
}
|
}
|
||||||
|
@ -396,7 +398,7 @@ fn (mut a array) push(val voidptr) {
|
||||||
// `val` is array.data
|
// `val` is array.data
|
||||||
// TODO make private, right now it's used by strings.Builder
|
// TODO make private, right now it's used by strings.Builder
|
||||||
pub fn (mut a3 array) push_many(val voidptr, size int) {
|
pub fn (mut a3 array) push_many(val voidptr, size int) {
|
||||||
if a3.data == val {
|
if a3.data == val && !isnil(a3.data) {
|
||||||
// handle `arr << arr`
|
// handle `arr << arr`
|
||||||
copy := a3.clone()
|
copy := a3.clone()
|
||||||
a3.ensure_cap(a3.len + size)
|
a3.ensure_cap(a3.len + size)
|
||||||
|
@ -406,7 +408,9 @@ pub fn (mut a3 array) push_many(val voidptr, size int) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
a3.ensure_cap(a3.len + size)
|
a3.ensure_cap(a3.len + size)
|
||||||
unsafe {C.memcpy(a3.get_unsafe(a3.len), val, a3.element_size * size)}
|
if !isnil(a3.data) && !isnil(val) {
|
||||||
|
unsafe {C.memcpy(a3.get_unsafe(a3.len), val, a3.element_size * size)}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
a3.len += size
|
a3.len += size
|
||||||
}
|
}
|
||||||
|
|
|
@ -356,7 +356,7 @@ fn converter(mut pn PrepNumber) u64 {
|
||||||
mut r2 := u32(0) // 96-bit precision integer
|
mut r2 := u32(0) // 96-bit precision integer
|
||||||
mut r1 := u32(0)
|
mut r1 := u32(0)
|
||||||
mut r0 := u32(0)
|
mut r0 := u32(0)
|
||||||
mask28 := u32(0xF<<28)
|
mask28 := u32(u64(0xF)<<28)
|
||||||
mut result := u64(0)
|
mut result := u64(0)
|
||||||
// working on 3 u32 to have 96 bit precision
|
// working on 3 u32 to have 96 bit precision
|
||||||
s0 = u32(pn.mantissa & u64(0x00000000FFFFFFFF))
|
s0 = u32(pn.mantissa & u64(0x00000000FFFFFFFF))
|
||||||
|
|
Loading…
Reference in New Issue