Conversation
| _ = inst; | ||
| const llvm_fn = self.getIntrinsic("llvm.trap", &.{}); | ||
| _ = self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, undefined, 0, .Cold, .Auto, ""); | ||
| _ = self.builder.buildUnreachable(); |
There was a problem hiding this comment.
Oh, sorry about that! That's why I was seeing Basic Block in function 'trap.main' does not have terminator!--thought maybe that only happened because I compiled in debug mode. It still gave me the LLVM IR and all so I thought it would be fine.
BTW, the CI just failed and it's the exact same CI failure that I've been getting on my two PRs where I previously updated zig1.wasm (but later removed those changes) (#13998 and #14782). I'm guessing I did follow the procedure the intended way after all if you're getting the same failure.
Because I got the same failure after updating zig1.wasm on two entirely unrelated PRs, I believe it's some issues directly related to that whole stage1 stuff, unrelated to @trap or something.
There was a problem hiding this comment.
I opened #14802 to hopefully prevent this from happening again. I haven't diagnosed the failure yet but I suspect it is likely caused by some of the recent changes to the C backend, or perhaps due to a limitation of our C WASI shims.
I'm sorry that happened to you and others, that must have been very confusing.
| #define zig_trap() __asm__ volatile("ud2"); | ||
| #else | ||
| #define zig_trap() raise(SIGILL) | ||
| #define zig_trap() raise(SIGTRAP) |
There was a problem hiding this comment.
I've previously explained my reasoning for SIGILL but now I think SIGILL is not much better or as good as SIGTRAP, anyway.
After some more research, now I would like to give out my recommendation to maybe use SIGSTOP or SIGKILL here as they are AFAIK the only signals that cannot be caught which I believe would be more appropriate here? I was going to demonstrate how they cannot be caught but these two asserts are perhaps demonstrative enough:
Lines 1160 to 1161 in e7f128c
Raising signals that cannot be caught might be more appropriate as trap/@trap is not a debugging tool but rather something that should in fact terminate the program for sure, as far as I understand it.
The difference between SIGSTOP and SIGKILL seems to be that SIGSTOP actually stops the program for later resumption which seems inappropriate so perhaps SIGKILL is best and safest of all here.
There was a problem hiding this comment.
I think "trap" is the best signal because it's called "trap". If the world doesn't treat it that way, the world is broken.
Perhaps this would have caught the problem we are seeing in #14799.
Perhaps this would have caught the problem we are seeing in #14799.
It needed an unreachable instruction after it.
Perhaps this would have caught the problem we are seeing in #14799.
Perhaps this would have caught the problem we are seeing in #14799.
This would have caught the problem we are seeing in #14799.
This would have caught the problem we are seeing in #14799.
This would have caught the problem we are seeing in #14799.
This would have caught the problem we are seeing in ziglang#14799.
follow-up to #14782