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

Is it necessary to catch SIGSEGV when checking the HW bound? #1058

Closed
gnh1201 opened this issue Mar 23, 2022 · 2 comments
Closed

Is it necessary to catch SIGSEGV when checking the HW bound? #1058

gnh1201 opened this issue Mar 23, 2022 · 2 comments

Comments

@gnh1201
Copy link
Contributor

gnh1201 commented Mar 23, 2022

A system that triggers SIGSEGV when trying to check HW bound. I've mentioned this before. #802

Although this problem can be solved by adding the flag(-DWAMR_DISABLE_HW_BOUND_CHECK=1), I don't think I know in advance if the target system has this problem.

Do these segmentation faults usually require a warning in advance or handling? I would like to get some advice.

@wenyongh
Copy link
Contributor

@gnh1201 The HW bound check is to use the hardware trap mechanism to implement the wasm memory access boundary check for AOT/JIT: runtime firstly registers a signal handler to catch the SIGSEGV signal, and when the wasm app accesses linear memory with address which is out of range (for example, linear memory size is 64KB, the address to read is larger than 64KB), the signal SIGSEGV will be triggered and caught by the signal handler, and in the signal handler, runtime handles the exception and continues to work. The main goal is to improve the performance, if not, runtime (AOT/JIT code) have to check whether the address is out of range manually, some extra instructions will be needed.

So it is normal that SIGSEGV is thrown when HW bound check is enabled, you can see it in GDB, but it doesn't mean that runtime runs failed, instead, please let wasm app continue to run (in GDB, run c), normally the "out of bounds memory access" exception will be thrown by runtime, and you can use wasm_runtime_get_exception to get the result. Could you please try again?

If runtime cannot correctly handle the signal, normally runtime will print unhandled SIGSEGV, si_addr:. Thanks.

@gnh1201
Copy link
Contributor Author

gnh1201 commented May 12, 2022

I finally solved this problem. Thanks for your advice. :)

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

No branches or pull requests

2 participants