-
Notifications
You must be signed in to change notification settings - Fork 971
fix(compiler): replace createInBoundsGEP1 with createGEP1 to prevent UB #4563
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
base: master
Are you sure you want to change the base?
Conversation
5efde1a to
46815f9
Compare
|
before after |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is fine. The comments are really redundant.
|
Also, no merging master to branch, use rebase instead in the future. I think you can:
This gains you a single commit for your changes here. |
Thanks, will reduce it to single line comment. |
Thank You, I really needed those tips since I did realise that unknowingly i pushed 5 commits into this PR, even though even doing pushing with no addition msg |
8a63fa4 to
bea642f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@ibmibmibm PTAL.
Summary: Replaces 'createInBoundsGEP1' with 'createGEP1' for memory access operations in the AOT compiler. This fixes a raw Segmentation Fault issue where the WasmEdge signal handler failed to trap out-of-bounds accesses. Root Cause: WasmEdge's zero-cost bounds checking relies on pointers legally hitting the OS Guard Page to trigger a SIGSEGV. The LLVM 'inbounds' keyword contract states that pointers must stay within allocated objects. When a pointer hits the Guard Page, this contract is violated, resulting in Undefined Behavior (Poison). This UB allowed LLVM to optimize away the necessary trap mechanics. Fix: Using standard 'createGEP1' (without 'inbounds') forces the compiler to generate the exact pointer arithmetic required to hit the Guard Page and trigger the trap deterministically. Verification: - Checked LLVM IR: Verified 'inbounds' keyword is removed from generated 'getelementptr' instructions. - Runtime: Confirmed raw Segfault is replaced by graceful '[error] execution failed: out of bounds memory access'. Fixes WasmEdge#3063 Signed-off-by: blackdragoon26 <sankalp.jha9643@gmail.com>
bea642f to
197d032
Compare
Summary:
Replaces 'createInBoundsGEP1' with 'createGEP1' for memory access operations in the AOT compiler. This fixes a raw Segmentation Fault issue where the WasmEdge signal handler failed to trap out-of-bounds accesses.
Root Cause:
WasmEdge's zero-cost bounds checking relies on pointers legally hitting the OS Guard Page to trigger a SIGSEGV.
The LLVM 'inbounds' keyword contract states that pointers must stay within allocated objects. When a pointer hits the Guard Page, this contract is violated, resulting in Undefined Behavior (Poison). This UB allowed LLVM to optimize away the necessary trap mechanics.
Fix:
Using standard 'createGEP1' (without 'inbounds') forces the compiler to generate the exact pointer arithmetic required to hit the Guard Page and trigger the trap deterministically.
Verification:
Fixes #3063