Skip to content

Commit d5291f2

Browse files
authored
ci: add ubsan check (#101)
1 parent b389294 commit d5291f2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
test:
11-
runs-on: "ubuntu-18.04"
11+
runs-on: "ubuntu-20.04"
1212
env:
1313
OPENRESTY_PREFIX: "/usr/local/openresty"
1414

@@ -39,7 +39,7 @@ jobs:
3939

4040
- name: Get dependencies
4141
run: |
42-
sudo apt install -y cpanminus build-essential libncurses5-dev libreadline-dev libssl-dev perl luarocks
42+
sudo apt install -y cpanminus build-essential libncurses5-dev libreadline-dev libssl-dev perl luarocks libubsan0
4343
sudo luarocks install lua-resty-http > build.log 2>&1 || (cat build.log && exit 1)
4444
4545
wget https://github.com/tinygo-org/tinygo/releases/download/v0.20.0/tinygo_0.20.0_amd64.deb
@@ -55,7 +55,9 @@ jobs:
5555
wget https://raw.githubusercontent.com/api7/apisix-build-tools/master/build-apisix-base.sh
5656
chmod +x build-apisix-base.sh
5757
OR_PREFIX=$OPENRESTY_PREFIX CC="clang -fsanitize=address -fcolor-diagnostics -Qunused-arguments" \
58-
cc_opt="-Werror" ./build-apisix-base.sh latest
58+
cc_opt="-Werror -fsanitize=undefined" \
59+
ld_opt="-lubsan" \
60+
./build-apisix-base.sh latest
5961
6062
- name: Script
6163
run: |

src/http/ngx_http_wasm_module.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ ngx_http_wasm_init(ngx_conf_t *cf)
199199
}
200200

201201

202+
/* To avoid complex error handling, we choose to allocate several objects together.
203+
* The downside is that the objects are not alignment, but it is fine under x86 & ARM64, which
204+
* are the only platforms supported by most of the Wasm VM. */
205+
__attribute__((no_sanitize("undefined")))
202206
void *
203207
ngx_http_wasm_load_plugin(const char *name, size_t name_len,
204208
const char *bytecode, size_t size)

0 commit comments

Comments
 (0)