Skip to content

Commit 57202f7

Browse files
committed
Merge branch 'master' into feature/trampoline-in-artifact
2 parents c91c448 + a663a15 commit 57202f7

File tree

18 files changed

+219
-37
lines changed

18 files changed

+219
-37
lines changed

.github/workflows/benchmark.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
# that are needed during the build process. Additionally, this works
3636
# around a bug in the 'cache' action that causes directories outside of
3737
# the workspace dir to be saved/restored incorrectly.
38-
run: echo "::set-env name=CARGO_HOME::$(pwd)/.cargo_home"
38+
run: echo "CARGO_HOME=$(pwd)/.cargo_home" >> $GITHUB_ENV
3939
- name: Cache
4040
uses: actions/cache@master
4141
with:
@@ -56,8 +56,8 @@ jobs:
5656
curl --proto '=https' --tlsv1.2 -sSf https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz -L -o llvm.tar.xz
5757
mkdir -p /opt/llvm-10
5858
tar xf llvm.tar.xz --strip-components=1 -C /opt/llvm-10
59-
echo ::add-path::/opt/llvm-10/bin
60-
echo ::set-env name=LLVM_SYS_100_PREFIX::/opt/llvm-10
59+
echo '/opt/llvm-10/bin' >> $GITHUB_PATH
60+
echo 'name=LLVM_SYS_100_PREFIX=/opt/llvm-10' >> $GITHUB_ENV
6161
- name: Install Python
6262
uses: actions/setup-python@v2
6363
with:

.github/workflows/coverage.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ jobs:
2929
curl --proto '=https' --tlsv1.2 -sSf https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz -L -o llvm.tar.xz
3030
mkdir -p /opt/llvm-10
3131
tar xf llvm.tar.xz --strip-components=1 -C /opt/llvm-10
32-
echo ::add-path::/opt/llvm-10/bin
33-
echo ::set-env name=LLVM_SYS_100_PREFIX::/opt/llvm-10
32+
echo '/opt/llvm-10/bin' >> $GITHUB_PATH
33+
echo 'LLVM_SYS_100_PREFIX=/opt/llvm-10' >> $GITHUB_ENV
3434
- name: Generate Coverage Report
3535
run: |
3636
cargo install cargo-tarpaulin

.github/workflows/main.yaml

+9-9
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
# that are needed during the build process. Additionally, this works
8282
# around a bug in the 'cache' action that causes directories outside of
8383
# the workspace dir to be saved/restored incorrectly.
84-
run: echo "::set-env name=CARGO_HOME::$(pwd)/.cargo_home"
84+
run: echo "CARGO_HOME=$(pwd)/.cargo_home" >> $GITHUB_ENV
8585
- name: Cache
8686
uses: actions/cache@master
8787
with:
@@ -103,13 +103,13 @@ jobs:
103103
# key: cargo-sccache-bin-${{ env.CARGO_SCCACHE_VERSION }}
104104
# - name: Install sccache
105105
# run: |
106-
# echo "::add-path::${{ runner.tool_cache }}/cargo-sccache/bin"
106+
# echo "${{ runner.tool_cache }}/cargo-sccache/bin" >> $GITHUB_PATH
107107
# cargo install sccache --version ${{ env.CARGO_SCCACHE_VERSION }} --root ${{ runner.tool_cache }}/cargo-sccache
108108
# - name: Start sccache
109109
# run: |
110110
# ${{ runner.tool_cache }}/cargo-sccache/bin/sccache --start-server
111111
# ${{ runner.tool_cache }}/cargo-sccache/bin/sscache -s
112-
# echo "::set-env name=RUSTC_WRAPPER::${{ runner.tool_cache }}/cargo-sccache/bin/sccache"
112+
# echo "RUSTC_WRAPPER=${{ runner.tool_cache }}/cargo-sccache/bin/sccache" >> $GITHUB_ENV
113113
- name: Install LLVM (Windows)
114114
if: matrix.os == 'windows-latest'
115115
shell: cmd
@@ -118,17 +118,17 @@ jobs:
118118
# run: |
119119
# curl --proto '=https' --tlsv1.2 -sSf https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/LLVM-10.0.0-win64.exe -L -o llvm-installer.exe
120120
# 7z x llvm-installer.exe -oC:/llvm-10
121-
# echo ::add-path::C:/llvm-10/bin
122-
# echo ::set-env name=LLVM_SYS_100_PREFIX::C:/llvm-10
123-
# echo ::set-env name=LIBCLANG_PATH::C:/llvm-10/bin/libclang.dll
121+
# echo C:/llvm-10/bin >> $GITHUB_PATH
122+
# echo "LLVM_SYS_100_PREFIX=C:/llvm-10" >> $GITHUB_ENV
123+
# echo "LIBCLANG_PATH=C:/llvm-10/bin/libclang.dll" >> $GITHUB_ENV
124124
- name: Install LLVM (Unix)
125125
if: matrix.os != 'windows-latest'
126126
run: |
127127
curl --proto '=https' --tlsv1.2 -sSf ${{ matrix.llvm_url }} -L -o llvm.tar.xz
128128
mkdir -p ${{ env.LLVM_DIR }}
129129
tar xf llvm.tar.xz --strip-components=1 -C ${{ env.LLVM_DIR }}
130-
echo "::add-path::${{ env.LLVM_DIR }}/bin"
131-
echo "::set-env name=LLVM_SYS_100_PREFIX::${{ env.LLVM_DIR }}"
130+
echo "${{ env.LLVM_DIR }}/bin" >> $GITHUB_PATH
131+
echo "LLVM_SYS_100_PREFIX=${{ env.LLVM_DIR }}" >> $GITHUB_ENV
132132
env:
133133
LLVM_DIR: ${{ github.workspace }}/llvm-10
134134
- name: Set up dependencies for Mac OS
@@ -248,7 +248,7 @@ jobs:
248248
path: ${{ runner.tool_cache }}/cargo-audit
249249
key: cargo-audit-bin-${{ env.CARGO_AUDIT_VERSION }}
250250
- run: |
251-
echo "::add-path::${{ runner.tool_cache }}/cargo-audit/bin"
251+
echo "${{ runner.tool_cache }}/cargo-audit/bin" >> $GITHUB_PATH
252252
- run: |
253253
cargo install cargo-audit --version ${{ env.CARGO_AUDIT_VERSION }} --root ${{ runner.tool_cache }}/cargo-audit
254254
cargo audit

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@
1010
- [#1710](https://github.com/wasmerio/wasmer/pull/1710) Memory for function call trampolines is now owned by the Artifact.
1111
### Added
1212

13+
- [#1715](https://github.com/wasmerio/wasmer/pull/1715) Register errors from `wasm_module_serialize` in the Wasm C API.
1314
- [#1709](https://github.com/wasmerio/wasmer/pull/1709) Implement `wasm_module_name` and `wasm_module_set_name` in the Wasm(er) C API.
1415
- [#1700](https://github.com/wasmerio/wasmer/pull/1700) Implement `wasm_externtype_copy` in the Wasm C API.
1516

17+
### Fixed
18+
19+
- [#1718](https://github.com/wasmerio/wasmer/pull/1718) Fix panic in the API in some situations when the memory's min bound was greater than the memory's max bound.
20+
1621
## 1.0.0-alpha4 - 2020-10-08
1722

1823
### Added

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,11 @@ test-llvm = [
131131

132132
test-native = [
133133
"native",
134+
"test-generator/test-native",
134135
]
135136
test-jit = [
136137
"jit",
138+
"test-generator/test-jit",
137139
]
138140

139141
# Specifies that we're running in coverage testing mode. This disables tests

Makefile

+10-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ else
88
UNAME_S :=
99
endif
1010

11-
compilers :=
11+
# Which compilers we build. These have dependencies that may not on the system.
12+
compilers := cranelift
13+
14+
# Which engines we test. We always build all engines.
15+
engines := jit
1216

1317
ifeq ($(ARCH), x86_64)
14-
# In X64, Cranelift is enabled
15-
compilers += cranelift
1618
# LLVM could be enabled if not in Windows
1719
ifneq ($(OS), Windows_NT)
1820
# Singlepass doesn't work yet on Windows
@@ -29,10 +31,14 @@ ifeq ($(ARCH), x86_64)
2931
compilers += llvm
3032
endif
3133
endif
34+
35+
# Native engine doesn't work yet on Windows
36+
engines += native
3237
endif
3338
endif
3439

3540
compilers := $(filter-out ,$(compilers))
41+
engines := $(filter-out ,$(engines))
3642

3743
ifneq ($(OS), Windows_NT)
3844
bold := $(shell tput bold)
@@ -94,7 +100,7 @@ build-capi-llvm:
94100
# Testing #
95101
###########
96102

97-
test: $(foreach compiler,$(compilers),test-$(compiler)-jit) test-packages test-examples test-deprecated
103+
test: $(foreach engine,$(engines),$(foreach compiler,$(compilers),test-$(compiler)-$(engine))) test-packages test-examples test-deprecated
98104

99105
# Singlepass and native engine don't work together, this rule does nothing.
100106
test-singlepass-native:

examples/engine_headless.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
147147
}
148148

149149
#[test]
150-
#[cfg(not(windows))]
150+
#[cfg(not(any(windows, target_arch = "aarch64")))]
151151
fn test_engine_headless() -> Result<(), Box<dyn std::error::Error>> {
152152
main()
153153
}

examples/engine_native.rs

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
8787
}
8888

8989
#[test]
90+
#[cfg(not(target_arch = "aarch64"))]
9091
fn test_engine_native() -> Result<(), Box<dyn std::error::Error>> {
9192
main()
9293
}

lib/api/src/tunables.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::{MemoryType, Pages, TableType};
2-
use more_asserts::assert_ge;
32
use std::cmp::min;
43
use std::sync::Arc;
54
use target_lexicon::{OperatingSystem, PointerWidth};
@@ -67,7 +66,6 @@ impl BaseTunables for Tunables {
6766
// If the module doesn't declare an explicit maximum treat it as 4GiB.
6867
let maximum = memory.maximum.unwrap_or_else(Pages::max_value);
6968
if maximum <= self.static_memory_bound {
70-
assert_ge!(self.static_memory_bound, memory.minimum);
7169
MemoryStyle::Static {
7270
bound: self.static_memory_bound,
7371
offset_guard_size: self.static_memory_offset_guard_size,

lib/c-api/src/wasm_c_api/module.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ pub unsafe extern "C" fn wasm_module_serialize(
108108
) {
109109
let byte_vec = match module.inner.serialize() {
110110
Ok(byte_vec) => byte_vec,
111-
Err(_) => return,
111+
Err(err) => {
112+
crate::error::update_last_error(err);
113+
return;
114+
}
112115
};
113116
*out_ptr = byte_vec.into();
114117
}

lib/c-api/tests/wasm_c_api/test-memory.c

+60
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,66 @@ int main(int argc, const char *argv[]) {
6262
wasm_memorytype_delete(memtype3);
6363
wasm_memory_delete(memory3);
6464

65+
// =====================
66+
wasm_limits_t limits4 = {
67+
.min = 0x7FFFFFFF,
68+
.max = 0x7FFFFFFF,
69+
};
70+
own wasm_memorytype_t* memtype4 = wasm_memorytype_new(&limits4);
71+
own wasm_memory_t* memory4 = wasm_memory_new(store, memtype4);
72+
assert(memory4 == NULL);
73+
error = get_wasmer_error();
74+
printf("Found error string: %s\n", error);
75+
assert(0 == strcmp("The minimum requested (2147483647 pages) memory is greater than the maximum allowed memory (65536 pages)", error));
76+
free(error);
77+
78+
wasm_memorytype_delete(memtype4);
79+
80+
// =====================
81+
wasm_limits_t limits5 = {
82+
.min = 0x7FFFFFFF,
83+
.max = 0x0FFFFFFF,
84+
};
85+
own wasm_memorytype_t* memtype5 = wasm_memorytype_new(&limits5);
86+
own wasm_memory_t* memory5 = wasm_memory_new(store, memtype5);
87+
assert(memory5 == NULL);
88+
error = get_wasmer_error();
89+
printf("Found error string: %s\n", error);
90+
assert(0 == strcmp("The minimum requested (2147483647 pages) memory is greater than the maximum allowed memory (65536 pages)", error));
91+
free(error);
92+
93+
wasm_memorytype_delete(memtype5);
94+
95+
// =====================
96+
wasm_limits_t limits6 = {
97+
.min = 15,
98+
.max = 10,
99+
};
100+
own wasm_memorytype_t* memtype6 = wasm_memorytype_new(&limits6);
101+
own wasm_memory_t* memory6 = wasm_memory_new(store, memtype6);
102+
assert(memory6 == NULL);
103+
error = get_wasmer_error();
104+
printf("Found error string: %s\n", error);
105+
assert(0 == strcmp("The memory is invalid because the maximum (10 pages) is less than the minimum (15 pages)", error));
106+
free(error);
107+
108+
wasm_memorytype_delete(memtype6);
109+
110+
// =====================
111+
wasm_limits_t limits7 = {
112+
.min = 0x7FFFFFFF,
113+
.max = 10,
114+
};
115+
own wasm_memorytype_t* memtype7 = wasm_memorytype_new(&limits7);
116+
own wasm_memory_t* memory7 = wasm_memory_new(store, memtype7);
117+
assert(memory7 == NULL);
118+
error = get_wasmer_error();
119+
printf("Found error string: %s\n", error);
120+
assert(0 == strcmp("The minimum requested (2147483647 pages) memory is greater than the maximum allowed memory (65536 pages)", error));
121+
free(error);
122+
123+
wasm_memorytype_delete(memtype7);
124+
65125
printf("Shutting down...\n");
66126
wasm_store_delete(store);
67127
wasm_engine_delete(engine);

lib/compiler-cranelift/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ edition = "2018"
1515
wasmer-compiler = { path = "../compiler", version = "1.0.0-alpha4", features = ["translator"], default-features = false }
1616
wasmer-vm = { path = "../vm", version = "1.0.0-alpha4" }
1717
wasmer-types = { path = "../wasmer-types", version = "1.0.0-alpha4", default-features = false, features = ["std"] }
18-
cranelift-codegen = { version = "0.65", default-features = false }
18+
cranelift-codegen = { version = "0.65", default-features = false, features = ["x86", "arm64"] }
1919
cranelift-frontend = { version = "0.65", default-features = false }
2020
tracing = "0.1"
2121
hashbrown = { version = "0.8", optional = true }

tests/compilers/traps.rs

+52-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ fn test_trap_return() -> Result<()> {
3838
}
3939

4040
#[test]
41-
#[cfg_attr(feature = "test-singlepass", ignore)]
41+
#[cfg_attr(
42+
any(
43+
feature = "test-singlepass",
44+
feature = "test-native",
45+
target_arch = "aarch64",
46+
),
47+
ignore
48+
)]
4249
fn test_trap_trace() -> Result<()> {
4350
let store = get_store();
4451
let wat = r#"
@@ -118,7 +125,14 @@ fn test_trap_trace_cb() -> Result<()> {
118125
}
119126

120127
#[test]
121-
#[cfg_attr(feature = "test-singlepass", ignore)]
128+
#[cfg_attr(
129+
any(
130+
feature = "test-singlepass",
131+
feature = "test-native",
132+
target_arch = "aarch64",
133+
),
134+
ignore
135+
)]
122136
fn test_trap_stack_overflow() -> Result<()> {
123137
let store = get_store();
124138
let wat = r#"
@@ -149,7 +163,15 @@ fn test_trap_stack_overflow() -> Result<()> {
149163
}
150164

151165
#[test]
152-
#[cfg_attr(any(feature = "test-singlepass", feature = "test-llvm"), ignore)]
166+
#[cfg_attr(
167+
any(
168+
feature = "test-singlepass",
169+
feature = "test-llvm",
170+
feature = "test-native",
171+
target_arch = "aarch64",
172+
),
173+
ignore
174+
)]
153175
fn trap_display_pretty() -> Result<()> {
154176
let store = get_store();
155177
let wat = r#"
@@ -182,7 +204,15 @@ RuntimeError: unreachable
182204
}
183205

184206
#[test]
185-
#[cfg_attr(any(feature = "test-singlepass", feature = "test-llvm"), ignore)]
207+
#[cfg_attr(
208+
any(
209+
feature = "test-singlepass",
210+
feature = "test-llvm",
211+
feature = "test-native",
212+
target_arch = "aarch64",
213+
),
214+
ignore
215+
)]
186216
fn trap_display_multi_module() -> Result<()> {
187217
let store = get_store();
188218
let wat = r#"
@@ -387,7 +417,14 @@ fn mismatched_arguments() -> Result<()> {
387417
}
388418

389419
#[test]
390-
#[cfg_attr(any(feature = "test-singlepass", feature = "test-llvm"), ignore)]
420+
#[cfg_attr(
421+
any(
422+
feature = "test-singlepass",
423+
feature = "test-llvm",
424+
feature = "test-native"
425+
),
426+
ignore
427+
)]
391428
fn call_signature_mismatch() -> Result<()> {
392429
let store = get_store();
393430
let binary = r#"
@@ -418,7 +455,15 @@ RuntimeError: indirect call type mismatch
418455
}
419456

420457
#[test]
421-
#[cfg_attr(any(feature = "test-singlepass", feature = "test-llvm"), ignore)]
458+
#[cfg_attr(
459+
any(
460+
feature = "test-singlepass",
461+
feature = "test-llvm",
462+
feature = "test-native",
463+
target_arch = "aarch64",
464+
),
465+
ignore
466+
)]
422467
fn start_trap_pretty() -> Result<()> {
423468
let store = get_store();
424469
let wat = r#"
@@ -450,6 +495,7 @@ RuntimeError: unreachable
450495
}
451496

452497
#[test]
498+
#[cfg_attr(feature = "test-native", ignore)]
453499
fn present_after_module_drop() -> Result<()> {
454500
let store = get_store();
455501
let module = Module::new(&store, r#"(func (export "foo") unreachable)"#)?;

0 commit comments

Comments
 (0)