Commit Graph

101 Commits

Author SHA1 Message Date
YAMAMOTO Takashi
f8b4ca2a70
sandboxed-system-primitives: Remove unused file signals.h (#1132) 2022-04-27 18:59:09 +08:00
YAMAMOTO Takashi
e1934f2478
sandboxed-system-primitives: Use d_ino=0 for NuttX (#1128)
NuttX doesn't have d_ino.
2022-04-27 17:49:06 +08:00
YAMAMOTO Takashi
5343411623
libc-wasi/sandboxed-system-primitives: Convert signals only when available (#1125)
Many of these signal constants are not available on NuttX.

Maybe we can remove these signal stuff sooner or later:
    https://github.com/WebAssembly/WASI/issues/7
    https://github.com/WebAssembly/wasi-libc/pull/278
2022-04-27 16:22:43 +08:00
YAMAMOTO Takashi
2fe83e29cd
sandboxed-system-primitives: make CPT/TCT clock ids optional (#1126)
NuttX doesn't have them.
2022-04-27 14:24:02 +08:00
Xu Jun
5ab368dd00
Support va_args in libc-builtin (#1117)
Implement vprintf/sprintf/snprintf wrapper functions for libc-builtin.
2022-04-24 10:39:18 +08:00
Wenyong Huang
d6e781af28
Add more operand stack overflow checks for fast-interp (#1104)
And clear some compile warnings on Windows
2022-04-20 16:19:12 +08:00
Wenyong Huang
d4758d7380
Refine codes and fix several issues (#1094)
Add aot relocation for ".rodata.str" symbol to support more cases
Fix some coding style issues
Fix aot block/value stack destroy issue
Refine classic/fast interpreter codes
Clear compile warning of libc_builtin_wrapper.c in 32-bit platform
2022-04-18 17:33:30 +08:00
YAMAMOTO Takashi
2366e8c493
Fix a few signedness warnings (#1095)
Fix compile warnings in libc-wasi posix.c:
```
posix.c:880:41: warning: comparison of integers of different signs:
 'unsigned long' and 'ssize_t' (aka 'long') [-Wsign-compare]
            if (bufoff + iov[i].buf_len < len) {
posix.c:1359:32: warning: comparison of integers of different signs:
 'off_t' (aka 'long long') and 'unsigned long long' [-Wsign-compare]
    if (ret == 0 && sb.st_size < offset + len)
```
2022-04-18 16:54:15 +08:00
Xu Jun
8589ed155d
Fix %ld specifier issue in libc-builtin printf wrapper (#1088)
The format specifiers of %ld/%lu/%li/%lx/%lp/%lo (or %z* and %t* like) should
be treated as 32-bit integer in wasm.
And merge the handle of unsigned/signed for %u/%d and %llu/%lld specifier
when calling snprintf.
2022-04-14 14:02:19 +08:00
Xu Jun
87c67eb6f0
Enhance printf_wrapper in libc-builtin (#1074)
Use snprintf to format the string and then output it,
so as to support more formats and reduce the footprint.
2022-04-12 17:13:18 +08:00
Wenyong Huang
4864302a1f
Fix wasi implementation issues (#1078)
Fix args_get and environ_get issues in libc-wasi and libc-uvwasi implementation.
2022-04-11 11:55:37 +08:00
Xu Jun
24afd4e7cb
Preserve execution memory for debug instance (#1072)
During debugging, the debug client may request to malloc a memory space
to evaluate the user expressions. If we malloc memory from the linear memory,
it may fail when the thread is in stop status. We preserve a buffer during
creating debug instance, and use a simple bump pointer allocator to serve lldb's
memory request.
2022-04-04 08:23:55 +08:00
liang.he
559a0502f1
Enable socket-api recvmsg() and sendmsg() (#1042)
Implement socket-api `recvmsg()` and `sendmsg()` for wasm app,
add sample and update document.
2022-03-30 15:57:40 +08:00
Wenyong Huang
5264ce4118
Fix issues reported by klocwork (#1060)
Fix issues reported by klocwork, fix host_tool compile error,
and update build script of benchmark jetstream
2022-03-24 17:34:22 +08:00
Wenyong Huang
38b07b3614
Add libuv and uvwasi to attributions (#1057) 2022-03-24 10:05:10 +08:00
Hanged Fish
a02cc6626d
Fix libc-wasi not working in spawned exec_env (#1053)
In thread_manager.c, `wasm_cluster_spawn_exec_env` creates a new module
instance but not sets wasi_ctx, so when the new exec_env calls wasm function
which uses WASI API, the WASI API functions in `libc_wasi_wrapper.c` will get
null result in calling `get_wasi_ctx`  and then return `wasi_errno`.

Signed-off-by: HangedFish <bravohangedman@outlook.com>
2022-03-22 12:17:14 +08:00
Wenyong Huang
21d89135da
Enhance uvwasi build process and fix wamrc windows build error (#1046)
And update related document
2022-03-15 21:43:55 +08:00
Wenyong Huang
9c87a1ee17
Implement part of Berkeley Socket API for libc-wasi (#1036)
Refer to [Networking API design](https://github.com/WebAssembly/WASI/issues/370)
and [feat(socket): berkeley socket API v2](https://github.com/WebAssembly/WASI/pull/459):

- Support the socket API of synchronous mode, including `socket/bind/listen/accept/send/recv/close/shutdown`,
    the asynchronous mode isn't supported yet.
- Support adding `--addr-pool=<pool1,pool2,..>` argument for command line to identify the valid ip address range
- Add socket-api sample and update the document
2022-03-10 15:13:38 +08:00
Xu Jun
3fe191b0df
[debugger enhance] don't block gdbserver thread while executing (#989)
Allow to set break point again when all break points are removed and
wasm app starts running.
2022-02-16 17:35:35 +08:00
Xu Jun
5f8c7655a7
Fix pthread_getspecific return value (#999)
Fix pthread_getspecific return value as mentioned in #995
2022-02-05 22:45:59 +08:00
Xu Jun
68fd6454c2
Fix debug thread not created issue (#983)
And fix a double free issue when starting debug server failed
2022-01-26 09:56:01 +08:00
Xu Jun
90a0057d33
Implement pthread_cond_broadcast wrapper for lib-pthread (#982)
Implement pthread_cond_broadcast wrapper for lib-pthread
- support pthread_cond_broadcast wrapper for posix/linux-sgx/windows
- update document for building multi-thread wasm app with emcc
2022-01-25 09:28:02 +08:00
Wenyong Huang
552f85075d
Fix __wasi_subscription_t inconsistent with wasi-libc issue (#964)
Fix __wasi_subscription_t structure definition inconsistent with wasi-libc
definition issue, reported by #961, tested with sleep, poll API and other
wasi cases on x86-64, x86-32 and arm32 targets.
2022-01-17 20:52:45 +08:00
Wenyong Huang
092efbfe21
Fix thread manager issues (#962)
Fix the issue that joining a detached thread might result in joining hang,
resolve the issue by adding wait_count for a thread's exec_env to indicate
whether a thread needs to detach itself or not when it exits.

And add checks for the input exec_env for cluster's join/detach/cancel thread.
2022-01-17 17:09:04 +08:00
Xu Jun
ee97e30a1a
Fix pointer unchecked issue in thread-mgr.c (#960)
And refine the code format of thread_manager.h
2022-01-14 17:57:59 +08:00
Wenyong Huang
308d31c621
Upgrade uvwasi to 1.42.0 and fix Android link issues (#938)
Upgrade uvwasi to 1.42.0 and fix Android link issues reported by #934
2022-01-06 18:25:37 +08:00
Huang Qi
9169eff8bb
Remove hardcoded stack size in thread_manager.c (#931)
Remove hardcoded stack size in thread_manager.c

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-01-05 13:16:25 +08:00
Xu Jun
ccb2de35d7
Enable source debugging feature for windows platform (#910)
- use platform independent data types in debug-engine library
- add os_socket APIs and provide windows and posix implementation
- avoid using platform related header files in non-platform layer
- use format specifiers macros for sprintf and sscanf
- change thread handle type from uint64 to korp_tid
- add lock when sending socket packet to avoid thread racing
2021-12-22 19:52:07 +08:00
Huang Qi
4cc4625a2b
Cleanup output format warnings (#904)
Use `PRIxxx` related macros to format the output strings so as to clear
compile warnings, e.g. PRIu32, PRId32, PRIX32, PRIX64 and so on.
And add the related macro definitions in platform_common.h if they
are not defined, as some compilers might not support them.
2021-12-20 15:51:36 +08:00
zhouliang3
2917a0c814
libc-builtin: Fix the signature of strncasecmp native function (#888)
Fix the signature invalid issue in libc-builtin, modify signature of strncasecmp
native function from "($$i)" to "($$i)i".
2021-12-13 19:40:05 +08:00
Wenyong Huang
5547924e28
Refine codes and fix several issues (#882)
Refine some codes in wasm loader
Add -Wshadow to gcc compile flags and fix some variable shadowed issues
Fix function parameter/return types not checked issue
Fix fast-interp loader reserve_block_ret() not handle V128 return type issue
Fix mini loader load_table_segment_section() failed issue
Add detailed comments for argc argument in wasm_runtime_call_wasm()
2021-12-10 18:13:17 +08:00
Huang Qi
915b26b0ec
Remove hardcoded stack size while creating pthread (#881)
Use original module instance's default_wasm_stack_size instead,
which is the stack size used to instantiate it.
2021-12-10 15:11:45 +08:00
Xu Jun
2af5ae5abb
[source debug] refine some code in source debugging (#856)
- move the wait_cond from exec_env to debug_instance, so the debug thread can be waken up by any threads
- process more general query message from debugger
- refine debug instance create/destroy mechanism
- avoid creating debug instance during module instantiating
- avoid blocking execution thread during creating debug instance
- update related documents
2021-12-06 10:25:38 +08:00
Xu Jun
9b0b33e4ae
fix duplicated debug instance id in multiple native thread issue (#847)
The debug_instance_list is not protected by mutex, and the debug instance uses
the length of this list as its id. If several threads create debug instance at the
same time, they may get duplicated/same ids. This patch adds mutex to protect
this list.
2021-11-25 12:15:37 +08:00
zhouliang3
e64b6e8120
Fix bug of destroy_callback_list not cleared when thread mgr destroy (#844)
The destroy_callback_list variable in thread_manager_destroy is not cleared.
When wamr is started as a task, after exiting and restarting, it will loop
endlessly in traverse_list.

Signed-off-by: zhouliang3 <zhouliang3@xiaomi.com>
2021-11-23 10:57:01 +08:00
Xu Jun
703e724c99
[source debug] process ModuleInfo query message (#815) 2021-11-02 12:09:15 +08:00
Xu Jun
83df8600f7
Support random debug port by assigning port = 0 (#807)
Support random debug port by assigning port = 0,
and update help and document.
2021-10-30 02:44:41 -05:00
Qinkun Bao
40ca5469dc
Remove duplicated wasi_dircookie_t typedef in libc_wasi_wrapper.h (#808)
Remove duplicated wasi_dircookie_t typedef in libc_wasi_wrapper.h to
fix clang warnings.
2021-10-30 14:41:57 +08:00
Wenyong Huang
5face80e0c
Fix spec test workflow issue and CI Dockerfile issue (#810)
Fix llvm binaries cache missed issue in spec test workflow,
fix CI Dockerfile issue and refine code format for libc_builtin_wrapper.c.
2021-10-30 09:24:03 +08:00
Wenyong Huang
3dff80157b
Fix app heap corrupted unchecked issue (#788)
Check whether app heap is corrupted in gc_migrate() and gci_dump(),
and handle the failures in wasm/aot_enlarge_memory().
2021-10-15 20:56:41 +08:00
Carlos
dd9b4e021e
Fix WASI type/macro misalignments (#766)
Some of the WASI definitions in libc-wasi are out of sync with those of [wasi-libc](https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/headers/public/wasi/api.h).

This PR fixed the misalignments of type __wasi_dirnamlen_t, __wasi_linkcount_t and __wasi_dirent_t, and WASI RIGHT related macros.
2021-10-14 21:56:30 +08:00
Wenyong Huang
fb4afc7ca4
Apply clang-format for core/iwasm compilation and libraries (#784)
Apply clang-format for core/iwasm/compilation and core/iwasm/libraries files.
Add wasm-c-api empty_imports sample to workflow test.
And enable triggering workflow when core/config.h changes.
2021-10-13 15:13:00 +08:00
Xu Jun
0be1f687af
Fix source debugging issues (#776)
- fix data race issue between debug control thread and main thread
- fix possible memory leaks in breakpoints list
- fix memory uninitialized issues
- remove unused data structures
- add more checks when handling packet and args
- fix mini-loader issues
- fix config_common.cmake fast interp prompt issue
2021-10-09 15:56:58 +08:00
Wenyong Huang
9ef37dd781
Implement source debugging for interpreter and AOT (#769)
Implement source debugging feature for classic interpreter and AOT:
- use `cmake -DWAMR_BUILD_DEBUG_INTERP=1` to enable interpreter debugging
- use `cmake -DWAMR_BUILD_DEBUG_AOT=1` to enable AOT debugging

See doc/source_debugging.md for more details.
2021-09-29 13:36:46 +08:00
YAMAMOTO Takashi
336abc2b27
Fix a build on alpine, whose libc is musl (#726)
Change __syscall_slong_t to __SYSCALL_SLONG_TYPE, and use it when macro __SYSCALL_SLONG_TYPE is defined.
2021-09-07 10:03:54 +08:00
YAMAMOTO Takashi
e80715f352
lib-pthread: Fix pthread_create callback arg issue (#701)
The last argument arg of pthread_create passed from wasm app is opaque
for the library and host, it should be returned back to the wasm app without
any interpretation. There is no point to translate it to a native address.
Actually it harms because the validation seems broken.
2021-08-19 18:21:56 +08:00
Huang Qi
8fd89bd415
Implement clock() wrapper for built-in libc (#691) 2021-08-07 21:21:25 +08:00
Wenyong Huang
28f104036c
Fix some compile warnings and update document (#670)
And implement clock_gettime wrapper for libc-built.
2021-07-22 19:39:53 +08:00
Wenyong Huang
1a4aa5ac2f
Enable multi-thread for tensorflow sample, update wasm-c-api document (#651) 2021-06-14 08:58:32 +08:00
Wenyong Huang
1b34606940
Move application entry APIs out of wasm_runtime_common.c (#639)
And fix libc-builtin print float issue
Add a list to track all third party components
Fix compile error when MEMORY_TRACING is enabled

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-05-26 13:22:03 +08:00