Commit Graph

172 Commits

Author SHA1 Message Date
Benbuck Nason
1c2a8fca4e
Fix some more spelling issues (#3393) 2024-05-08 09:30:29 +08:00
Benbuck Nason
ca61184ced
Fix some spelling issues (#3385)
Fix some of the spelling issues found by CSpell.
2024-05-06 07:56:48 +08:00
YAMAMOTO Takashi
120b9659dd
A few native stack detection fixes for macOS/arm64 (#3368) 2024-04-26 19:37:55 +08:00
YAMAMOTO Takashi
410ee580ae
Add wasm_runtime_detect_native_stack_overflow_size (#3355)
- Add a few API (https://github.com/bytecodealliance/wasm-micro-runtime/issues/3325)
   ```c
   wasm_runtime_detect_native_stack_overflow_size
   wasm_runtime_detect_native_stack_overflow
   ```
- Adapt the runtime to use them
- Adapt samples/native-stack-overflow to use them
- Add a few missing overflow checks in the interpreters
- Build and run the sample on the CI
2024-04-26 16:00:58 +08:00
YAMAMOTO Takashi
1b5ff93656
CI: Use macos-13 instead of macos-latest (#3366)
Our workflows assume macos-latest is intel, but now it's arm64.
Use macos-13, which is documented to be intel, instead.

reference:
https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners
2024-04-26 14:38:49 +08:00
TianlongLiang
f14a166466
Test more samples in nightly-run CI (#3358)
Build and run sample native-lib and wamr-app-framework's simple
in nightly-run CI.
2024-04-25 20:58:28 +08:00
YAMAMOTO Takashi
9d6d3466ff
Fix a few native stack address calculations (#3351) 2024-04-24 16:39:38 +08:00
Huang Qi
0aeef69d23
Update binary size info in README.md (#3030)
And also show size in CI with NuttX.

The size info is from bloaty, which is a tool to measure binary size.
Example usage and output (WAMR stuff only):

```
➜  sim bloaty -s file nuttx/nuttx -d compileunits -n 10000 --source-filter wamr
    FILE SIZE        VM SIZE
 --------------  --------------
  13.1%   108Ki  19.4%  14.6Ki    wamr/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c
  12.2%   100Ki   0.1%      50    wamr/core/iwasm/common/wasm_c_api.c
  10.6%  87.1Ki   8.7%  6.54Ki    wamr/core/iwasm/common/wasm_runtime_common.c
   9.2%  76.1Ki  12.6%  9.45Ki    wamr/core/iwasm/aot/aot_loader.c
   8.9%  73.6Ki  12.5%  9.38Ki    wamr/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c
   7.1%  58.7Ki   9.0%  6.79Ki    wamr/core/iwasm/aot/aot_runtime.c
   3.6%  29.3Ki   5.6%  4.21Ki    wamr/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c
   3.2%  26.2Ki   3.6%  2.73Ki    wamr/core/shared/platform/common/posix/posix_socket.c
   2.9%  24.0Ki   2.7%  2.01Ki    wamr/core/iwasm/common/wasm_memory.c
   2.8%  23.2Ki   2.3%  1.74Ki    wamr/core/iwasm/common/wasm_application.c
   2.6%  21.5Ki   3.3%  2.46Ki    wamr/core/shared/platform/common/posix/posix_file.c
   2.5%  20.4Ki   1.9%  1.45Ki    wamr/core/iwasm/common/wasm_native.c
   2.4%  20.0Ki   2.0%  1.51Ki    wamr/core/iwasm/aot/arch/aot_reloc_riscv.c
   2.1%  17.3Ki   1.6%  1.20Ki    wamr/core/iwasm/common/wasm_shared_memory.c
   2.0%  16.4Ki   2.4%  1.81Ki    wamr/core/shared/mem-alloc/ems/ems_alloc.c
   1.9%  15.9Ki   2.4%  1.81Ki    wamr/product-mini/platforms/nuttx/main.c
   1.7%  13.8Ki   1.4%  1.05Ki    wamr/core/iwasm/aot/aot_intrinsic.c
   1.5%  12.2Ki   0.4%     312    wamr/core/iwasm/common/wasm_exec_env.c
   1.4%  11.8Ki   0.8%     618    wamr/core/shared/platform/common/posix/posix_thread.c
   1.0%  8.20Ki   1.2%     952    wamr/core/shared/utils/bh_hashmap.c
   0.9%  7.52Ki   0.8%     636    wamr/core/shared/utils/bh_vector.c
   0.9%  7.46Ki   0.8%     618    wamr/core/shared/mem-alloc/ems/ems_kfc.c
   0.8%  6.89Ki   1.0%     744    wamr/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.c
   0.8%  6.65Ki   0.5%     356    wamr/core/shared/platform/nuttx/nuttx_platform.c
   0.5%  4.25Ki   0.4%     316    wamr/core/shared/utils/bh_common.c
   0.4%  3.70Ki   0.3%     248    wamr/core/shared/utils/bh_log.c
   0.4%  3.52Ki   0.4%     330    wamr/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/random.c
   0.4%  3.07Ki   0.1%      40    wamr/core/shared/mem-alloc/mem_alloc.c
   0.3%  2.52Ki   0.3%     196    wamr/core/shared/utils/uncommon/bh_read_file.c
   0.3%  2.36Ki   0.3%     216    wamr/core/shared/platform/common/posix/posix_clock.c
   0.3%  2.27Ki   0.1%     106    wamr/core/shared/utils/bh_list.c
   0.2%  1.91Ki   0.6%     430    wamr/core/shared/platform/common/libc-util/libc_errno.c
   0.2%  1.78Ki   0.1%      94    wamr/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/str.c
   0.2%  1.73Ki   0.0%       6    wamr/core/iwasm/common/wasm_blocking_op.c
   0.2%  1.42Ki   0.1%      74    wamr/core/shared/utils/bh_bitmap.c
   0.1%  1.02Ki   0.1%      82    wamr/core/shared/platform/common/posix/posix_time.c
   0.1%     751   0.2%     138    wamr/core/iwasm/common/arch/invokeNative_riscv.S
 100.0%   823Ki 100.0%  75.1Ki    TOTAL
```
2024-04-23 17:15:53 +08:00
TianlongLiang
30426be82c
Refactor CodeQL CI (#3319)
- Move CodeQL scripts to the scripts directory
- Only report error in CI if it's a CodeQL reported issue and was not dismissed
  before and is likely to be an actual error
2024-04-16 16:32:47 +08:00
liang.he
fef26ead3e
addr2line.py: Support sourceMappingURL section produced by emcc (#3302)
And update the debug-tools sample.
2024-04-12 11:43:40 +08:00
dependabot[bot]
1a043b6eb5
Bump actions/upload-artifact from 3 to 4 (#3308)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-12 11:34:06 +08:00
dependabot[bot]
ff7bf7ad41
Bump actions/setup-node from 3 to 4 (#3307)
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3 to 4.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-12 11:33:30 +08:00
dependabot[bot]
b54551598a
Bump github/codeql-action from 2 to 3 (#3306)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-12 11:31:05 +08:00
liang.he
19a6eb98b0
Add dependabot (#3303) 2024-04-11 19:56:02 +08:00
TianlongLiang
4a29794a1b
Update release CI (#3295)
In the release CI and related scripts, when comparing and printing to the CI,
use the most recent **ancestor** tag(s) for the release branch rather than
the most recent one(s).

And fix the build_wamr_sdk.yml and build_wamr_lldb.yml CIs.
2024-04-09 16:51:36 +08:00
Wenyong Huang
2013f1f7d7
Fix warnings/issues reported in Windows and by CodeQL/Coverity (#3275)
Fix the warnings and issues reported:
- in Windows platform
- by CodeQL static code analyzing
- by Coverity static code analyzing

And update CodeQL script to build exception handling and memory features.
2024-04-07 11:57:31 +08:00
Wenyong Huang
a23fa9f86c
Implement memory64 for classic interpreter (#3266)
Adding a new cmake flag (cache variable) `WAMR_BUILD_MEMORY64` to enable
the memory64 feature, it can only be enabled on the 64-bit platform/target and
can only use software boundary check. And when it is enabled, it can support both
i32 and i64 linear memory types. The main modifications are:

- wasm loader & mini-loader: loading and bytecode validating process 
- wasm runtime: memory instantiating process
- classic-interpreter: wasm code executing process
- Support memory64 memory in related runtime APIs
- Modify main function type check when it's memory64 wasm file
- Modify `wasm_runtime_invoke_native` and `wasm_runtime_invoke_native_raw` to
  handle registered native function pointer argument when memory64 is enabled
- memory64 classic-interpreter spec test in `test_wamr.sh` and in CI

Currently, it supports memory64 memory wasm file that uses core spec
(including bulk memory proposal) opcodes and threads opcodes.

ps.
https://github.com/bytecodealliance/wasm-micro-runtime/issues/3091
https://github.com/bytecodealliance/wasm-micro-runtime/pull/3240
https://github.com/bytecodealliance/wasm-micro-runtime/pull/3260
2024-04-02 15:22:07 +08:00
Wenyong Huang
b1502258ea
Fix CI error when install packages for macos-14 (#3270)
MacOS CI ran failed with "error: externally-managed-environment" reported
when installing dependencies. Add argument "--break-system-packages" to
fix it.

ps.
https://github.com/bytecodealliance/wasm-micro-runtime/actions/runs/8503917001/job/23291537189
https://github.com/bytecodealliance/wasm-micro-runtime/actions/runs/8502961539/job/23289867170
2024-04-01 15:27:15 +08:00
TianlongLiang
b9740beb31
Disable CodeQL on fork repo (#3262) 2024-03-28 16:17:48 +08:00
Wenyong Huang
ca364eb5d7
Fix nightly-run CI and CodeQL CI (#3250)
- Fix nightly run CI failure which was introduced by PR #3239 and now it must set
  WAMR_BUILD_TARGET when building iwasm for Android platform
- Remove building llvm, wamrc and jit in CodeQL CI, since it will
  do static code analyzing for llvm project and cause CodeQL run
  failed: `Oops! A fatal internal error occurred.
  This particular kind of error most often happens as a side effect of running out of
  disk space.`
2024-03-22 14:29:30 +08:00
Wenyong Huang
6a55bde5b3
Add issue templates (#3248)
Add issue templates of blank issue, improvement and reporting bug in WAMR.
And fix several invalid links in ATTRIBUTIONS.md.
2024-03-22 13:49:39 +08:00
Wenyong Huang
e003ee1e29
CodeQL: Add more build combinations and disable run on PR (#3246)
Enhance CodeQL Code Security Analysis:
- Add more compilation combinations to build iwasm with different kinds of features
- Disable run on PR created and keep nightly run, since the whole time is very long,
   and will check how to restore run on PR created in the future
2024-03-21 14:18:27 +08:00
Brian
a86eeb273c
Add CodeQL Workflow for Code Security Analysis (#2812)
Add CodeQL Workflow for Code Security Analysis

This pull request introduces a CodeQL workflow to enhance the security analysis of our repository.
CodeQL is a powerful static analysis tool that helps identify and mitigate security vulnerabilities in
our codebase. By integrating this workflow into our GitHub Actions, we can proactively identify
and address potential issues before they become security threats.

We added a new CodeQL workflow file (.github/workflows/codeql.yml) that
- Runs on nightly-run, and consider runs on every pull request to the main branch in the future.
- Excludes queries with a high false positive rate or low-severity findings.
- Does not display results for third-party code, focusing only on our own codebase.

Testing:
To validate the functionality of this workflow, we have run several test scans on the codebase and
reviewed the results. The workflow successfully compiles the project, identifies issues, and provides
actionable insights while reducing noise by excluding certain queries and third-party code.

Deployment:
Once this pull request is merged, the CodeQL workflow will be active and automatically run on
every push and pull request to the main branch. To view the results of these code scans, please
follow these steps:
1. Under the repository name, click on the Security tab.
2. In the left sidebar, click Code scanning alerts.

Additional Information:
- You can further customize the workflow to adapt to your specific needs by modifying the workflow file.
- For more information on CodeQL and how to interpret its results, refer to the GitHub documentation
and the CodeQL documentation.

Signed-off-by: Brian <bayuan@purdue.edu>
2024-03-21 12:37:47 +08:00
Wenyong Huang
76254183f9
Make android platform's cmake flags configurable (#3239)
Don't hardcode the cmake configurations in the Android platform's CMakeLists.txt.

Fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/3238
2024-03-21 11:08:40 +08:00
TianlongLiang
7486056aee
Fix nightly run tsan ASLR issue (#3233)
The nightly run CI reported error:
  "FATAL: ThreadSanitizer: unexpected memory mapping 0x5be565bf3000-0x5be565bfb000"
which is caused by the ASLR issue, we set `vm.mmap_rnd_bits` to 28 to resolve it,
according to the post below:
https://stackoverflow.com/questions/77850769/fatal-threadsanitizer-unexpected-memory-mapping-when-running-on-linux-kernels

ps.
https://github.com/bytecodealliance/wasm-micro-runtime/actions/runs/8319242277/job/22762363873#step:14:2008
2024-03-18 11:15:47 +08:00
Enrico Loparco
0e4c4799b1
Get location info from function indexes in addr2line script (#3206)
Update the `addr2line` script so that:
- line info is printed in a more convenient format, e.g.
```
0: c
        at wasm-micro-runtime/test-tools/addr2line/trap.c:5:1
1: b
        at wasm-micro-runtime/test-tools/addr2line/trap.c:11:12
2: a
        at wasm-micro-runtime/test-tools/addr2line/trap.c:17:12
```
similar to how Rust prints stack traces when there's a panic. In an IDE, the user
can conveniently click on the printed path and be redirected to the file line.
- a new `--no-addr` argument can be provided to the script 

It can be used in fast interpreter mode (that is not supported by the script otherwise)
or with older wamr versions (where the stack trace only had the function index info
and not the function address). In that case, `wasm-objdump` is used to get the function
name from the index and `llvm-dwarfdump` to obtain the location info (where the line
refers to the start of the function).
2024-03-08 10:20:04 +08:00
Enrico Loparco
7692f32a94
Allow overriding max memory on module instantiation (#3198)
This PR adds a max_memory_pages parameter to module instantiation APIs,
to allow overriding the max memory defined in the WASM module.

Sticking to the max memory defined in the module is quite limiting when
using shared memory in production. If targeted devices have different
memory constraints, many wasm files have to be generated with different
max memory values. And device constraints may not be known in advance.

Being able to set the max memory value during module instantiation allows
to reuse the same wasm module, e.g. by retrying instantiation with different
max memory value.
2024-03-05 17:53:26 +08:00
TianlongLiang
0fa0beba94
VSCode IDE enhancement and readme update (#3172)
- Temporarily disable the deque test for the VS Code extension, as the
  Rust formatter seems to malfunction after a recent VS Code update.
- Add configuration for iwasm host managed heap size, allowing users
  to flexibly `malloc` memory. This also fixes the current bug that when
  default size is 0, it can't run and debug.
- Apply coding style formatting for WAMR IDE source code and add a
  format check for it in CI.
- Update document and some screenshots.
2024-02-22 12:36:49 +08:00
Wenyong Huang
63cd567b3f
Separate app-manager and app-framework from WAMR (#3129)
As planned, the app-manager and app-framework are to be migrated to
https://github.com/bytecodealliance/wamr-app-framework.

ps.
https://github.com/bytecodealliance/wasm-micro-runtime/issues/2329
https://github.com/bytecodealliance/wasm-micro-runtime/wiki/TSC-meeting-notes
2024-02-20 18:12:36 +08:00
Wenyong Huang
16a4d71b34
Implement GC (Garbage Collection) feature for interpreter, AOT and LLVM-JIT (#3125)
Implement the GC (Garbage Collection) feature for interpreter mode,
AOT mode and LLVM-JIT mode, and support most features of the latest
spec proposal, and also enable the stringref feature.

Use `cmake -DWAMR_BUILD_GC=1/0` to enable/disable the feature,
and `wamrc --enable-gc` to generate the AOT file with GC supported.

And update the AOT file version from 2 to 3 since there are many AOT
ABI breaks, including the changes of AOT file format, the changes of
AOT module/memory instance layouts, the AOT runtime APIs for the
AOT code to invoke and so on.
2024-02-06 20:47:11 +08:00
Enrico Loparco
a32b082d2a
Add ARM MacOS to the CI (#3120)
Add ARM MacOS to the CI, to prevent regressions like the one fixed in #3102 in the future.
And add the AOT compilation to the wasi-threads example.
2024-02-03 11:51:02 +08:00
Marcin Kolny
a27ddece7f
Always allocate linear memory using mmap (#3052)
With this approach we can omit using memset() for the newly allocated memory
therefore the physical pages are not being used unless touched by the program.

This also simplifies the implementation.
2024-02-02 22:17:44 +08:00
Huang Qi
b98f150f82
CI: Update version of checkout to suppress warnings (#3093) 2024-01-27 07:55:49 +08:00
Huang Qi
54ef0e4de7
Bump NuttX version to 12.4.x in CI (#3047) 2024-01-19 11:24:48 +08:00
YAMAMOTO Takashi
b97370e3a8
samples/terminate: Add a sample to demonstrate wasm_runtime_terminate (#3043)
This is basically a modified copy of the "shared-module" example.
2024-01-18 15:01:03 +08:00
Marcin Kolny
ffa131b5ac
Allow using mmap for shared memory if hw bound check is disabled (#3029)
For shared memory, the max memory size must be defined in advanced. Re-allocation
for growing memory can't be used as it might change the base address, therefore when
OS_ENABLE_HW_BOUND_CHECK is enabled the memory is mmaped, and if the flag is
disabled, the memory is allocated. This change introduces a flag that allows users to use
mmap for reserving memory address space even if the OS_ENABLE_HW_BOUND_CHECK
is disabled.
2024-01-16 22:15:55 +08:00
Enrico Loparco
c9fd44e8b8
Build samples in debug mode (#3019)
Follow-up on #3008. Compiling samples in Debug mode allows us to
take advantage of asserts and would have prevented the fix in #3008.
2024-01-16 09:36:05 +08:00
Wenyong Huang
884c1abc11
Fix nightly-run CI failure (#3014)
Not know how to make `__attribute__((no_sanitize_address))` take effect
on gcc in Ubuntu-20.04, just disable quick AOT entry for wasm-c-api
sample in nightly-run CI.
2024-01-16 08:44:35 +08:00
Huang Qi
c6848e45a1
Using docker image for nuttx spectest (#2887)
And disable running the nuttx spectest CI every time PR merged since
it will consume too much runners to slow down the other checks.
2023-12-11 09:48:59 +08:00
Maks Litskevich
63696ba603
Fix typo in CI config and suppress STORE_U8 in TSAN (#2802)
This typo prevented sanitizers to work in the CI.
2023-12-11 09:16:30 +08:00
Huang Qi
2fb3dc3ec0
Add arm64 to nuttx compilation test (#2886) 2023-12-08 18:21:47 +08:00
Huang Qi
a58e596995
compilation_on_nuttx.yml: Use docker image to simplify env setup (#2878) 2023-12-07 18:03:07 +08:00
Huang Qi
39d0fabda3
Using stable branch for NuttX relative CI (#2872) 2023-12-06 16:09:17 +08:00
Huang Qi
7308b1eb00
Update FPU configuration in spec_test_on_nuttx.yml (#2856) 2023-12-04 18:57:18 +08:00
Huang Qi
453a29a9d4
Enable spectest on riscv64 (#2843)
Fix relocation issues on riscv and update test scripts and CI to enable
test spec cases on riscv QEMU.
2023-12-04 14:22:47 +08:00
Huang Qi
d7608690c0
Run spec test for classic/fast-interp in NuttX CI (#2817) 2023-11-27 15:24:02 +08:00
Huang Qi
748e745088
Disable FPU in NuttX spec test (#2781)
Fix spec test failure on NuttX with #2780, see:
https://github.com/bytecodealliance/wasm-micro-runtime/actions/runs/6910450452
2023-11-18 09:09:30 +08:00
YAMAMOTO Takashi
562a5dd1b6
Fix data/elem drop (#2747)
Currently, `data.drop` instruction is implemented by directly modifying the
underlying module. It breaks use cases where you have multiple instances
sharing a single loaded module. `elem.drop` has the same problem too.

This PR  fixes the issue by keeping track of which data/elem segments have
been dropped by using bitmaps for each module instances separately, and
add a sample to demonstrate the issue and make the CI run it.

Also add a missing check of dropped elements to the fast-jit `table.init`.

Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2735
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2772
2023-11-18 08:50:16 +08:00
TianlongLiang
503d94ace2
Enable more LLVM backends for the release wamrc binary (#2778)
As mentioned in https://github.com/bytecodealliance/wasm-micro-runtime/issues/2504,
the current release `wamrc` only has X86 target enabled. This PR enables
more targets for release `wamrc`, including AArch64, ARM, Mips and RISCV.
2023-11-16 18:32:28 +08:00
Huang Qi
56bfae774c
Update RISC-V compilers in Nuttx compilation CI and spec test CI (#2756)
Update RISC-V compilers in Nuttx compilation CI and spec test CI
to test workflows.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-11-14 09:21:58 +08:00