Commit Graph

1341 Commits

Author SHA1 Message Date
Marcin Kolny
ff4be24726
Fix bh_assert for 64-bit platforms (#2071)
In some cases, the memory address of some variables may have 4 least significant
bytes set to zero. Because we cast the pointer to int, we look only at 4 least
significant bytes; the assertion may fail because 4 least significant bytes are 0.

Change bh_assert implementation to cast the assert expr to int64_t and it works
well with 64-bit architectures.
2023-03-28 12:18:39 +08:00
Thomas Devoogdt
61369d48fd
libc-wasi/posix.c: Fix POLL{RD,WR}NORM in uClibc (#2069)
POLLRDNORM/POLLWRNORM may be not defined in uClibc, so replace them
with the equivalent POLLIN/POLLOUT.

Refer to https://www.man7.org/linux/man-pages/man2/poll.2.html
  POLLRDNORM Equivalent to POLLIN
  POLLWRNORM Equivalent to POLLOUT

Signed-off-by: Thomas Devoogdt <thomas.devoogdt@barco.com>
2023-03-28 11:20:31 +08:00
liang.he
d0fb2716b6
Fix several issues in CI binary releasing (#2064) 2023-03-26 12:19:45 +08:00
Enrico Loparco
0f73ce1076
Update wasi-libc version in CI and implement custom sync primitives (#2028)
Update wasi-libc version to resolve the hang issue when running wasi-threads cases.

Implement custom sync primitives as a counterpart of `pthread_barrier_wait` to
attempt to replace pthread sync primitives since they seem to cause data races
when running with the thread sanitizer.
2023-03-26 09:03:26 +08:00
Wenyong Huang
0faec7c96c
Update version to 1.2.0 and update release notes (#2062) 2023-03-25 20:25:54 +08:00
Wenyong Huang
605c8b07dc
Fix issue of Multi-tier JIT (#2056) 2023-03-25 11:15:05 +08:00
Wang Xin
b0f614d77a
Add architecture diagram for wasm globals and classic-interp stack frame (#2058) 2023-03-25 09:39:20 +08:00
Jämes Ménétrey
09a2698bba
Remove a file test outside of the specs and improve CI reporting (#2057)
Remove the test in the sample of file interaction that tries to extend the file
at the end, because this is not supported by the specifications of fseek.
The WASI exit code is now propagated by the runtime, so the CI will
indicate when a test is failing.
2023-03-24 21:24:23 +08:00
Wenyong Huang
c7cdb78394
Fix issues reported by Coverity (#2053)
Fix the potential dead lock issue reported by Coverity code analysis tool.
2023-03-24 14:05:17 +08:00
Wenyong Huang
3977f0b22a
Use pre-created exec_env for instantiation and module_malloc/free (#2047)
Use pre-created exec_env for instantiation and module_malloc/free,
use the same exec_env of the current thread to avoid potential
unexpected behavior.

And remove unnecessary shared_mem_lock in wasm_module_free,
which may cause dead lock.
2023-03-23 19:19:47 +08:00
Xu Jun
4c2d358980
Update document for source debugging (#2051) 2023-03-23 19:16:56 +08:00
dongheng
d975a1a82c
Enable platform support for esp-idf v5.0.1 (#2050) 2023-03-23 17:29:57 +08:00
Wang Xin
db2a4104b3
Add architecture document for wasm export (#2049) 2023-03-23 17:13:17 +08:00
Enrico Loparco
bfbe51e1b3
fix debugger: Set termination flags also when in debug mode (#2048)
When using multiple threads, termination flags are checked to stop the thread
if a `proc_exit` or trap occurs. They have to be set also in debug mode.

Tested using [WASI thread tests](https://github.com/bytecodealliance/wasm-micro-runtime/tree/main/core/iwasm/libraries/lib-wasi-threads/test).
2023-03-23 14:10:47 +08:00
Wang Xin
d06d2d3754
Add architecture diagram for wasm function (#2046) 2023-03-23 10:37:38 +08:00
Wenyong Huang
49d439a3bc
Fix/Simplify the atomic.wait/nofity implementations (#2044)
Use the shared memory's shared_mem_lock to lock the whole atomic.wait and
atomic.notify processes, and use it for os_cond_reltimedwait and os_cond_notify,
so as to make the whole processes actual atomic operations:
the original implementation accesses the wait address with shared_mem_lock
and uses wait_node->wait_lock for os_cond_reltimedwait, which is not an atomic
operation.

And remove the unnecessary wait_map_lock and wait_lock, since the whole
processes are already locked by shared_mem_lock.
2023-03-23 09:21:16 +08:00
Huang Qi
ea50bd2aca
Support dump call stack on exception and dump call stack on nuttx (#2042) 2023-03-22 18:11:53 +08:00
TianlongLiang
0ee6e18a06
Rename parameter names in wasm_runtime_instantiate (#2045) 2023-03-22 17:39:08 +08:00
Xu Jun
d75cb3224f
Fix dead lock in source debugger (#2040) 2023-03-20 08:17:22 +08:00
Wang Xin
5c37ddfbca
fix readme broken links (#2039) 2023-03-19 08:40:51 +08:00
Wang Xin
c2b73eabe2
Readme refactoring (#2038) 2023-03-19 08:05:57 +08:00
Enrico Loparco
83659fa42a
Use wasi-sdk 20 pre-release for tests with threads (#2021)
`wasi-sdk-20` pre-release can be used to avoid building `wasi-libc` to enable threads.
It's not possible to use `wasi-sdk-20` pre-release on Ubuntu 20.04 because of
incompatibility with the glibc version:
```bash
/opt/wasi-sdk/bin/clang: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found
(required by /opt/wasi-sdk/bin/clang)
```
2023-03-17 20:02:03 +08:00
Georgii Rylov
23e9a356e5
Enable to run wasi-thread tests with AOT (#2026) 2023-03-16 08:22:03 +08:00
liang.he
915b4d2a89
Fix few wasm-c-api python binding issues (#2029)
How to python language binding test cases:
```
$ cd <wamr_dir>/language-bindings/python
$ python -m pip install -e .
$ cd wasm-c-api
$ python -m unittest tests/test_basic.py
$ python -m unittest tests/test_advanced.py
```
2023-03-15 12:34:34 +08:00
Wenyong Huang
05d7ec30b1
Add libsodium benchmark (#2025) 2023-03-15 08:24:08 +08:00
Wenyong Huang
bab2402b6e
Fix atomic.wait, get wasi_ctx exit code and thread mgr issues (#2024)
- Remove notify_stale_threads_on_exception and change atomic.wait
  to be interruptible by keep waiting and checking every one second,
  like the implementation of poll_oneoff in libc-wasi
- Wait all other threads exit and then get wasi exit_code to avoid
  getting invalid value
- Inherit suspend_flags of parent thread while creating new thread to
  avoid terminated flag isn't set for new thread
- Fix wasi-threads test case update_shared_data_and_alloc_heap
- Add "Lib wasi-threads enabled" prompt for cmake
- Fix aot get exception, use aot_copy_exception instead
2023-03-15 07:47:36 +08:00
Georgii Rylov
2de24587a8
Fix wait_info data race for deletion and fix atomic_wait logic (#2016)
Fix a data race for test main_proc_exit_wait.c from #1963.
And fix atomic_wait logic that was wrong before:
- a thread 1 started executing wasm instruction wasm_atomic_wait
  but hasn't reached waiting on condition variable
- a main thread calls proc_exit and notifies all the threads that reached
  waiting on condition variable
Which leads to thread 1 hang on waiting on condition variable after that

Now it's atomically checked whether proc_exit was already called.
2023-03-13 10:19:17 +08:00
Wenyong Huang
578fbc5a55
Fix fast-jit build error (#2023) 2023-03-12 20:17:49 +08:00
Enrico Loparco
ea6cef7e51
Fix malloc non-thread-safe usage in lib-wasi-threads test (#2022)
In the WASI thread test modified in this PR, malloc was used in multiple threads
without a lock. But wasi-libc implementation of malloc is not thread-safe.
2023-03-11 10:44:37 +08:00
Hritik Gupta
ff3887757e
Add internal tests for socket apis (#1900) 2023-03-09 12:31:06 +08:00
Enrico Loparco
128c0ea899
Add internal tests for WASI threads (#1963)
Add internal tests for WASI threads. These tests are run in addition to
the ones in the proposal:
https://github.com/WebAssembly/wasi-threads/tree/main/test/testsuite.

The purpose is to test additional and more complex scenarios.
2023-03-09 09:03:16 +08:00
Wenyong Huang
289fc5efbf
Enhance/Fix sample socket-api and workload (#2006)
- Add python script to test socket-api cases
- Fix issues in socket-api send_recv wasm app
- Fix issues in building samples/workload/meshoptimizer
- Enhance build script of sample workload
2023-03-08 16:36:08 +08:00
tonibofarull
a15a731e12
wasi-nn: Support multiple TFLite models (#2002)
Remove restrictions:
- Only 1 WASM app at a time
- Only 1 model at a time
   - `graph` and `graph-execution-context` are ignored

Refer to previous document:
e8d718096d/core/iwasm/libraries/wasi-nn/README.md
2023-03-08 15:54:06 +08:00
Wenyong Huang
f279ba84ee
Fix multi-threading issues (#2013)
- Implement atomic.fence to ensure a proper memory synchronization order
- Destroy exec_env_singleton first in wasm/aot deinstantiation
- Change terminate other threads to wait for other threads in
  wasm_exec_env_destroy
- Fix detach thread in thread_manager_start_routine
- Fix duplicated lock cluster->lock in wasm_cluster_cancel_thread
- Add lib-pthread and lib-wasi-threads compilation to Windows CI
2023-03-08 10:57:22 +08:00
Marcin Kolny
7a3d2bfab6
Fix os_socket_addr_resolve() for IPv6 (#2015)
The function always specified IPv4 socklen to sockaddr_to_bh_sockaddr(),
therefore the assertion was failing; however, sockaddr_to_bh_sockaddr()
never actually used socklen parameter, so we deleted it completely.
2023-03-08 07:08:12 +08:00
Gustavo Henrique Nihei
6a3ae689f7
nuttx: Add missing pthread.h header (#2009) 2023-03-07 22:01:16 +08:00
Xu Jun
76b8225dac
Fix key error in build_llvm.py (#2014) 2023-03-07 17:48:26 +08:00
Kevin0626
e8fe2d1c42
support SSH for git clone llvm (#2011)
Co-authored-by: Kevin Kang <wilson.qch1685@gmail.com>
2023-03-07 17:05:36 +08:00
Huang Qi
2a5a2243e3
ci: Setup wasi-sdk for compilation on nuttx to fix break (#2012) 2023-03-07 12:06:38 +08:00
Wenyong Huang
5a7fbda7ac
Enable to collect code coverage of samples/simple (#2003) 2023-03-07 08:45:03 +08:00
Wenyong Huang
04616d398d
Fix wasm_cluster_create_thread issue (#2004)
In wasm_cluster_create_thread, the new_exec_env is added into the cluster's
exec_env list before the thread is created, so other threads can access the
fields of new_exec_env once the cluster->lock is unlocked, while the
new_exec_env's handle is set later inside the thread routine. This may result
in the new_exec_env's handle be invalidly accessed by other threads.
2023-03-06 18:51:13 +08:00
Xu Jun
e6a0184797
enable custom llvm build flags (#2000) 2023-03-06 06:50:53 +08:00
Enrico Loparco
e8d718096d
Add/reorganize locks for thread synchronization (#1995)
Attempt to fix data races when using threads.
- Protect access (from multiple threads) to exception and memory
- Fix shared memory lock usage
2023-03-04 08:15:26 +08:00
Enrico Loparco
1c44411a97
Add timeout to CI WASI tests and update WASI testsuite commit (#1997)
- Add timeout to CI WASI tests to avoid keeping CI node busy in case of
  deadlock in thread tests
- Update wasi-testsuite commit used, after fix in wasi-threads proposal
  https://github.com/WebAssembly/wasi-threads/pull/40
2023-03-03 16:30:59 +08:00
Wenyong Huang
1be202fad8
Fix several issues found (#1996)
- CMakeLists.txt: add lib_export.h to install list
- Fast JIT: enlarge spill cache size to enable several standalone cases
                when hw bound check is disabled
- Thread manager: wasm_cluster_exit_thread may destroy an invalid
               exec_env->module_inst when exec_env was destroyed before
- samples/socket-api: fix failure to run timeout_client.wasm
- enhance CI build wasi-libc and sample/wasm-c-api-imports CMakeLlist.txt
2023-03-03 15:00:54 +08:00
YAMAMOTO Takashi
9f0c4b63ac
doc/memory_usage.md: Update after dev/wasi_threads merge (#1994) 2023-03-01 05:19:34 +08:00
Wenyong Huang
9b9ae0cfac
Update cmake files and wamr-test-suites to support collect code coverage (#1992)
Support collecting code coverage with wamr-test-suites script by using
lcov and genhtml tools, eg.:
  cd tests/wamr-test-suites
  ./test_wamr.sh -s spec -b -P -C

The default code coverage and html files are generated at:
  tests/wamr-test-suites/workspace/wamr.lcov
  tests/wamr-test-suites/workspace/wamr-lcov.zip

And update wamr-test-suites scripts to support testing GC spec cases to
avoid frequent synchronization conflicts between branch main and dev/gc.
2023-02-28 17:38:18 +08:00
tonibofarull
b4f0228497
Python WAMR API binding: Add malloc/free and register_native (#1989) 2023-02-28 16:19:17 +08:00
Enrico Loparco
4ca57a0228
Update WASI thread proposal tests in CI (#1985)
Update CI to run extended WASI threads tests included in the proposal
https://github.com/WebAssembly/wasi-testsuite/tree/prod/testsuite-all/tests/proposals/wasi-threads
2023-02-27 20:28:37 +08:00
Enrico Loparco
52e26e59cf
Add lock to protect the operations of accessing exec env (#1991)
Data race may occur when accessing exec_env's fields, e.g. suspend_flags
and handle. Add lock `exec_env->wait_lock` for them to resolve the issue.
2023-02-27 19:53:41 +08:00