Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve stack trace dump #2599

Merged

Conversation

eloparco
Copy link
Contributor

The main goal of this PR is to avoid the stack traces getting mixed up together when using multiple threads. This is achieved by using exception_lock(module_inst).

I also noticed that, when an exception occurs, the output is a bit confusing since every thread would report the exception and then iwasm reports it one additional time at the end. I think it makes sense to remove the error prints from each thread and report the exception only once at the end (after all threads have finished).

Before:

[11:34:16:265 - 1F610DB40]: Load module success.

[11:34:16:286 - 1F610DB40]: Memory instantiate:
[11:34:16:287 - 1F610DB40]:   page bytes: 65536, init pages: 1, max pages: 30
[11:34:16:288 - 1F610DB40]:   heap offset: 65536, heap size: 0

[11:34:16:499 - 1F610DB40]: Memory instantiate success.

#00 m
#01 l
#02 main
#03 __main_void
#04 _start


#00 f
#01 g
#02 h
#03 __wasi_thread_start_C
#04 wasi_thread_start

[11:34:17:806 - 16B093000]: /Users/eloparco/dev/forks/wasm-micro-runtime/core/iwasm/interpreter/wasm_interp_fast.c, line 4034, meet an exception Exception: unreachable
[11:34:17:794 - 1F610DB40]: /Users/eloparco/dev/forks/wasm-micro-runtime/core/iwasm/interpreter/wasm_interp_fast.c, line 4034, meet an exception Exception: unreachable

#00 m
#01 l
#02 main
#03 __main_void
#04 _start

Exception: unreachable

After:

[11:32:03:625 - 1F610DB40]: Load module success.

[11:32:03:642 - 1F610DB40]: Memory instantiate:
[11:32:03:643 - 1F610DB40]:   page bytes: 65536, init pages: 1, max pages: 30
[11:32:03:644 - 1F610DB40]:   heap offset: 65536, heap size: 0

[11:32:03:804 - 1F610DB40]: Memory instantiate success.

#00 f
#01 g
#02 h
#03 __wasi_thread_start_C
#04 wasi_thread_start


#00 m
#01 l
#02 main
#03 __main_void
#04 _start

Exception: unreachable

@eloparco eloparco force-pushed the eloparco/fix-threads-stack-trace branch 3 times, most recently from 10b729d to 5215686 Compare September 28, 2023 11:20
@eloparco
Copy link
Contributor Author

eloparco commented Sep 28, 2023

clang-12 has been removed from Ubuntu 22.04: https://github.com/actions/runner-images/blob/ubuntu22/20230924.1/images/linux/Ubuntu2204-Readme.md, that's why the coding guidelines job in this PR was failing.
Last job using 22.04.3 version 20230917.1.0 was still fine, but the latest 20230924.1.0 fails.

I changed the CI for format check to pin Ubuntu 20.04, so that we can keep using clang-12.

Copy link
Contributor

@wenyongh wenyongh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wenyongh wenyongh merged commit 0053962 into bytecodealliance:main Sep 29, 2023
368 checks passed
wenyongh added a commit to wenyongh/wasm-micro-runtime that referenced this pull request Sep 29, 2023
Improve stack trace dump and fix coding guideline CI (bytecodealliance#2599)
victoryang00 pushed a commit to victoryang00/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
…e#2599)

Avoid the stack traces getting mixed up together when multi-threading is enabled
by using exception_lock/unlock in dumping the call stacks.

And remove duplicated call stack dump in wasm_application.c.

Also update coding guideline CI to fix the clang-format-12 not found issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants