Commit Graph
1412 Commits
Author SHA1 Message Date
dongsheng28849455andGitHub 79b27c1934 Support muti-module for AOT mode (#2482)
Support muti-module for AOT mode, currently only implement the
multi-module's function import feature for AOT, the memory/table/
global import are not implemented yet.

And update wamr-test-suites scripts, multi-module sample and some
CIs accordingly.
2023-09-28 08:56:11 +08:00
Wenyong HuangandGitHub fff0e2ad1c Fix nightly run sanitizer error in Fast JIT (#2601)
Suppress a sanitizer integer overflow error in signed integer add operation
in Fast JIT.
2023-09-27 15:41:48 +08:00
Wenyong HuangandGitHub a50a438461 Ignore handling SIG_DFL/SIG_IGN for previous sig action (#2589) 2023-09-26 19:59:48 +08:00
Wenyong HuangandGitHub ade73f6142 Fix compilation error on Android platform (#2594)
The CI might use clang-17 to build iwasm for Android platform and it may
report compilation error:
https://github.com/bytecodealliance/wasm-micro-runtime/actions/runs/6308980430/job/17128073777

/home/runner/work/wasm-micro-runtime/wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.c:45:19: error: call to undeclared function 'preadv'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    ssize_t ret = preadv(fd, iov, iovcnt, offset);
                  ^

Explicitly declare preadv and pwritev in android platform header file to resolve it.
2023-09-26 16:13:12 +08:00
Wenyong HuangandGitHub 6382162711 Fix loader push_pop_frame_ref_offset (#2590)
`wasm_loader_push_pop_frame_offset` may pop n operands by using
`loader_ctx->stack_cell_num` to check whether the operand can be
popped or not. While `loader_ctx->stack_cell_num` is updated in the
later `wasm_loader_push_pop_frame_ref`, the check may fail if the stack
is in polymorphic state and lead to `ctx->frame_offset` underflow.

Fix issue #2577 and #2586.
2023-09-26 10:17:54 +08:00
YAMAMOTO TakashiandGitHub b622622096 samples/inst-context-threads: Add a brief explanation (#2592) 2023-09-26 10:00:33 +08:00
zoraaverandGitHub 913a1414ad Add support for closing/renumbering preopen fds (#2578)
There doesn't appear to be a clear reason not to support this behavior.
It seems it was disallowed previously as a precaution. See
https://github.com/bytecodealliance/wasmtime/commit/67e2e57b02cd244c004379690aa56d3d5e187153
for more context.
2023-09-26 09:31:32 +08:00
YAMAMOTO TakashiandGitHub 94f276eab0 test_wamr.sh: Bump wasi-testsuite version (#2568)
On posix-like platforms, the rest of wasi-threads tests
should pass after the recent changes including the following PRs:
#2516, #2524, #2529, #2571, #2576 and #2582.
2023-09-26 09:20:13 +08:00
Wenyong HuangandGitHub efb5cca93d Fix compile error of tsf benchmark (#2588)
Explicitly declare readdir_r in gpc_code_gen_util.c.
2023-09-25 20:25:01 +08:00
Alfred E. NeumayerandGitHub 99b47fd334 Support AOT compiler with LLVM 17 (#2567)
Adapt API usage to new interfaces where applicable, including LLVM function
usage, obsoleted llvm::Optional type and removal of unavailable headers.

Know issues:
- AOT static PGO isn't enabled
- LLVM JIT may run failed due to llvm_orc_registerEHFrameSectionWrapper
  isn't linked into iwasm
2023-09-25 19:00:46 +08:00
zoraaverandGitHub f474f3d668 Return __WASI_EINVAL from fd_prestat_dir_name (#2580)
Return a WASI error code (rather than a host POSIX one). In addition,
there is no need to return an error in the case that the provided buffer
is too large.
2023-09-25 18:40:12 +08:00
YAMAMOTO TakashiandGitHub 363f08975b Fix a few issues in "run_wasi_tests.sh: provide stdin by ourselves" (#2582)
Apply "provide stdin by ourselves" to the aot case and check the correct exit code.
2023-09-23 10:28:18 +08:00
TianlongLiangandGitHub 71e07a7fa4 Fix potential unaligned store issue when extra return value is v128 (#2583)
Unaligned store v128 value to the AOT function argument of the pointer for
the extra return value may cause segmentation fault.

Fix the issue reported in #2556.
2023-09-23 09:06:35 +08:00
zoraaverandGitHub 06527f724e Remove provision of unnecessary fd rights (#2579)
The WASI docs allow for fewer rights to be applied to an fd than requested but
not more. This behavior is also asserted in the rust WASI tests, so it's necessary
for those to pass as well.
2023-09-22 09:11:25 +08:00
YAMAMOTO TakashiandGitHub 0677288f22 run_wasi_tests.sh: Provide stdin by ourselves (#2576)
This improves test consistency between typical local environments and
github runners.

This is necessary for some of latest wasi-threads tests.

cf. https://github.com/yamt/toywasm/commit/570e6706312cbdccb9d5268347186b441a24444b
2023-09-22 08:57:48 +08:00
YAMAMOTO TakashiandGitHub cf97ee081f test_wamr.sh: Print a bit more meaningful message (#2574) 2023-09-21 18:39:12 +08:00
ZHU HaoandGitHub 47daaeecc7 Fix compiling error for RT-Thread (#2569)
struct dfs_fd has been deprecated
2023-09-21 13:33:03 +08:00
YAMAMOTO TakashiandGitHub c7a7db21b7 export_native_api.md: Add a note about thread termination (#2572) 2023-09-21 13:32:08 +08:00
YAMAMOTO TakashiandGitHub 6fca48d8e6 Fix inverted WASM_DISABLE_WAKEUP_BLOCKING_OP checks (#2571) 2023-09-21 11:56:21 +08:00
YAMAMOTO TakashiandGitHub 444b159963 Implement async termination of blocking thread (#2516)
Send a signal whose handler is no-op to a blocking thread to wake up
the blocking syscall with either EINTR equivalent or partial success.

Unlike the approach taken in the `dev/interrupt_block_insn` branch (that is,
signal + longjmp similarly to `OS_ENABLE_HW_BOUND_CHECK`), this PR
does not use longjmp because:
* longjmp from signal handler doesn't work on nuttx
  refer to https://github.com/apache/nuttx/issues/10326
* the singal+longjmp approach may be too difficult for average programmers
  who might implement host functions to deal with

See also https://github.com/bytecodealliance/wasm-micro-runtime/issues/1910
2023-09-20 18:11:52 +08:00
zoraaverandGitHub d436e846ab Add support for running tests on apple M1 macs (#2554) 2023-09-17 13:54:28 +08:00
Enrico LoparcoandGitHub 132378f30b Allow using custom signal handler from non-main thread (#2551)
Remove thread local attribute of prev_sig_act_SIGSEGV/SIGBUS to allow using
custom signal handler from non-main thread since in a thread spawned by
embedder, embedder may be unable to call wasm_runtime_init_thread_env to
initialize them.

And fix the handling of prev_sig_act when its sa_handler is SIG_DFL, SIG_IGN,
or a user customized handler.
2023-09-15 18:55:16 +08:00
YAMAMOTO TakashiandGitHub 9c34fc3514 Fix build with ancient GCC (4.8) (#2553)
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2552
2023-09-15 16:24:12 +08:00
liang.heandGitHub f697244f33 runtest.py: Show accurate case amount in summary (#2549)
Instead of showing the total case amount under *spec/test/core*, show
the accurate number of how many test cases were executed.
2023-09-15 10:01:08 +08:00
Enrico LoparcoandGitHub 83db970953 Add user to enlarge memory error callback (#2546) 2023-09-13 18:03:49 +08:00
YAMAMOTO TakashiandGitHub a6fda9b7ab Add an API to terminate instance (#2538)
Add API wasm_runtime_terminate to terminate a module instance
by setting "terminated by user" exception to the module instance.

And update the product-mini of posix platforms.

Note: this doesn't work for some situations like blocking system calls.
2023-09-13 17:09:31 +08:00
YAMAMOTO TakashiandGitHub f128150d43 fd_object_release: Preserve errno (#2535)
Preserve errno because this function is often used like
the following. The caller wants to report the error from the main
operation (`lseek` in this example), not from fd_object_release.

```
    off_t ret = lseek(fd_number(fo), offset, nwhence);
    fd_object_release(fo);
    if (ret < 0)
        return convert_errno(errno);
```
2023-09-08 12:26:32 +08:00
YAMAMOTO TakashiandGitHub 534a8cf9f4 Handle a return from wasi _start function correctly (#2529)
This fixes a few test cases in wasi-threads testsuite like wasi_threads_return_main_block.
And also move the special handling for "wasi proc exit" to a more appropriate place.
2023-09-08 11:49:04 +08:00
YAMAMOTO TakashiandGitHub 6c846acc59 Implement module instance context APIs (#2436)
Introduce module instance context APIs which can set one or more contexts created
by the embedder for a wasm module instance:
```C
    wasm_runtime_create_context_key
    wasm_runtime_destroy_context_key
    wasm_runtime_set_context
    wasm_runtime_set_context_spread
    wasm_runtime_get_context
```

And make libc-wasi use it and set wasi context as the first context bound to the wasm
module instance.

Also add samples.

Refer to https://github.com/bytecodealliance/wasm-micro-runtime/issues/2460.
2023-09-07 14:54:11 +08:00
Cengizhan PasaogluandGitHub af2f3c8759 Fix typo for IP address buffer (#2532) 2023-09-07 14:29:52 +08:00
YAMAMOTO TakashiandGitHub 151dfae49c Unifdef -U WASMTIME_SSP_STATIC_CURFDS (#2533)
The macro WASMTIME_SSP_STATIC_CURFDS isn't used in the source code,
remove the related macro control code.
2023-09-06 15:25:58 +08:00
Marcin KolnyandGitHub 4798b69f36 Add ARM aeabi symbol for clearing memory content in a specific range (#2531) 2023-09-06 13:17:16 +08:00
Enrico LoparcoandGitHub 709127d631 Add callback to handle memory.grow failures (#2522)
When embedding WAMR, this PR allows to register a callback that is
invoked when memory.grow fails.

In case of memory allocation failures, some languages allow to handle
the error (e.g. by checking the return code of malloc/calloc in C), some
others (e.g. Rust) just panic.
2023-09-05 16:41:52 +08:00
YAMAMOTO TakashiandGitHub 48b71a05fb libc-wasi: Remove unused code (#2528) 2023-09-04 19:14:56 +08:00
YAMAMOTO TakashiandGitHub 9e3904337e Revert "Return error when exception was raised after main thread finishes" (#2524)
This reverts commit 71d43f3ca1.
2023-09-04 18:01:09 +08:00
YAMAMOTO TakashiandGitHub 2e78230e06 set_exception_visitor: Remove the special case for wasi proc exit (#2525)
While wasi proc exit is not a real trap, what the runtime does on it is mostly same as
real traps. That is, kill the siblings threads and represent the exit/trap as the result of
the "process" to the user api. There seems no reason to distinguish it from real traps
here.

Note that:
- The target thread either doesn't care the specific exception type or ignore wasi
  proc exit by themselves. (clear_wasi_proc_exit_exception)
- clear_wasi_proc_exit_exception only clears local exception.
2023-09-04 16:52:19 +08:00
Marcin KolnyandGitHub 8c2dc1d011 Add unit tests for the tid allocator (#2519)
Add simple infrastructure to add more unit tests in the future. At the moment tests
are only executed on Linux, but can be extended to other platforms if needed.

Use https://github.com/google/googletest/ as a framework.
2023-09-04 13:21:10 +08:00
YAMAMOTO TakashiandGitHub 1ff41ebdc2 Implement os_usleep for posix (#2517) 2023-09-01 12:10:54 +08:00
YAMAMOTO TakashiandGitHub 382d52fc05 Stop abusing shared memory lock to protect exception (#2509)
Use a separate global lock instead.

Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2407
2023-08-31 20:39:08 +08:00
Marcin KolnyandGitHub 53d7027de0 Implement strict validation of thread IDs according to the specification (#2521) 2023-08-31 20:23:54 +08:00
Maks LitskevichandGitHub 411b903cee Add mutex stress test (#2472)
As a part of stress-testing we want to ensure that mutex implementation is working
correctly and protecting shared resource to be allocated from other threads when
mutex is locked.

This test covers the most common situations that happen when some program uses
mutexes like locks from various threads, locks from the same thread etc.
2023-08-30 19:01:44 +08:00
Jämes MénétreyandGitHub ff151fb7ba sgx-ra: Disable the building of samples (#2507) 2023-08-28 09:42:16 +08:00
Wenyong HuangandGitHub fa2f29fd8a Fix issues in releasing wamr-lldb (#2497)
- Update lldb patch due to swig was upgraded to 4.1 in macos
- Export LD_LIBRARY_PATH for searching libpython3.10.so when validating wamr-lldb
  in Ubuntu-20.04
- Rename lldb-wasm.patch to lldb_wasm.path
2023-08-23 12:56:11 +08:00
Wenyong HuangandGitHub 858d1dd69c Fix duplicate vector init in wasm_module_validate (#2498) 2023-08-23 12:35:46 +08:00
Xu JunandGitHub 377c3d7a38 Auto increase port number in lldb validation script (#2492) 2023-08-22 14:24:42 +08:00
liang.heandGitHub 2b30bb0fda Upgrade swig to 4.1 (#2491)
Upgrade to sig@4.1 when building wamr-lldb on MacOS since swig@3
had been disabled: https://formulae.brew.sh/formula/swig
2023-08-22 13:57:23 +08:00
Huang QiandGitHub 051dfbbb9e Fix a typo in is_win_platform (#2490) 2023-08-22 11:50:11 +08:00
Marcin KolnyandGitHub 7f996a4559 Update version number and release notes (#2378)
Update the version number to 1.2.3 and update the release notes.
2023-08-22 08:55:36 +08:00
tonibofarullandGitHub 59bedecc5e Fix set wasi args order (#2485)
set_wasi_args should be called before module instantiation.
2023-08-22 08:50:26 +08:00
liang.heandGitHub f0632edc37 Clone the input binary during wasm_module_validate (#2483) 2023-08-21 19:43:28 +08:00