-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
LDC 1.3, OS X, -flto=full: Fatal error in EH code: _Unwind_RaiseException #2208
Comments
If I recall correctly, we've had a bunch of failing |
There are two reasons this happened on ARM:
In your case, you aren't compiling druntime differently between when you hit this error and you don't? In that case, you might be hitting some version of the unsolved second reason. The only way to know is to dig down into the assembly, as Dan does in that linked forum post. |
One test I did was to build LDC turning on "Phobos LTO" as provided to by Kinke in the #2168 thread. I'm guessing that also turns on LTO for druntime as well, though it was not explicitly discussed. Is this what you are referring to? Either way, inlining seems a reasonable hypothesis. As mentioned, this only occurs with |
I have never tried LTO, so my question was whether the changes you're trying affect the ldc exception-handling code in druntime, as happens with the first reason listed above that has nothing to do with inlining, or only the codegen for your own D code, as happens with the second reason. It sounds like the latter, but I don't know how pervasive LTO is. |
Yep.
It can apparently be extremely pervasive, especially wrt. (cross-module) inlining.
Edit: Right, forgot about the fact that it doesn't happen with (full-)LTO-enabled stdlibs. So yeah, a brittle alignment issue seems likely, possibly caused by that LLVM EH handler bug seen on ARM and a special inlining scenario. |
Btw SemaphoreCI used to fail during unwinding for a 32-bit library unittest (#2074 (comment)), which went away when setting the proper default inlining threshold... |
I'm not sure whether it is clear beyond doubt yet that the issue is in LLVM's EH table generation, rather than our personality function code. |
I quickly looked at druntime's struct _Unwind_Exception
{
ulong exception_class;
...
} vs. struct _Unwind_Control_Block
{
char[8] exception_class;
...
} The former being the general variant and the latter the ARM version. While identical in size, this may influence the alignment (and padded size) of the struct. On a 32-bit x86 target, a D
and then this in the current LLVM libunwind source:
So I guess an |
Not only that, but having debugged that issue, the problem there was the way In other words, the real issue is stack corruption, which manifests finally in the exception-handler. It so happens in that case that the exception-handler causes the stack corruption in the first place, but Jon's situation might just be stack corruption caused some other way. It needs to be investigated.
Yeah, I've noted some small disparities before too, but I doubt they're the issue here. |
I just tried to reproduce on linux/x64 with the final official release of ldc 1.3.0 and can't seem to. I extracted the command to build |
@joakim-noah If you still have the linux
Why I suggest this, and a potential clue - If you look at the tsv-filter code calling getoptInorder/std.getopt, you'll see a long list of command line options. Nearly all trigger an exception on invalid input. The first 25 that take option args, through My reason for suggesting trying a few different cases on Linux is that perhaps the behavior might show up at a different point in this chain than on OS X. The other obvious thing is that there is a clear differentiating line. Having all the initial options work fine and all starting with If you're wondering what |
I'm unable to reproduce with the three other commands you gave either. Clearly this is a codegen issue related to LTO, not bugs in your code, if it doesn't hit you with other compile options. Of the three ways we hit this on ARM that I listed above, only the first was a problem with the D source, because it used a bunch of casts that didn't take ARM alignment requirements into account. If Johan or someone else can reproduce on OS X, it looks like this might be limited to that OS. I can't reproduce on linux. |
FWIW, I encountered this both on travis-ci (OS X) and on my own machine, so two environments. The travis build: here. Note that in the travis builds |
So this is working with LDC 1.5 and Xcode 9.0.1 now, right Jon? |
Sorry, no. Fails in the exactly the same way, when using The interesting property I reported in comment from July 19 still holds. The failure is triggered by exception handlers used in option callbacks a fair way down a long list of callbacks provided to std.getopt. (Apologies for not reporting this when the 1.5.0 release came out. It doesn't affect my normal testing because I had switched to Thin LTO. It showed up later when I ran the full test suite with Full LTO.) |
Does the problem show up on linux now? |
This problem occurs only on Xcode with Full LTO. |
I'm not able to reproduce these issues with the latest version of the compiler (ldc 1.24.0-beta1). There doesn't seem to be any value in continuing to leave this open. |
Seen this error before. Very similar to #1512. Occurs in-conjunction with exception handling being used to process erroneous command line arguments. This time with the
tsv-filter
program in tsv-utils. So a fair bit of exception handling. Example:This will result from an exception raised by trying to convert
z
to asize_t
usingstd.conv.to!size_t
. It only seems to happen with a few exception handling cases.This is with LDC 1.3 on OSX (xcode 8.3.3). Only occurs with optimized builds using
-flto=full
. Does not get triggered with-flto=thin
or having noflto
option. Interestingly, it did not occur when Phobos is built with LTO support (as described in #2168). Using-flto=full
did not cause a problem in this case. (Note that #2168 involvedstd.conv.to!double
. Possible relationship?) Also, does not occur with LDC 1.2, this is new in 1.3.I have switched my programs to use
-flto=thin
. This appears to work fine, so it is not a pressing issue for me. Naturally, my quick attempts to produce a simplified case did not succeed.For these reasons (and the time spent on #2168), I'm not planning on further investigation unless requested. It'd of course be nice if adding Phobos LTO support addressed this as well as #2168.
The text was updated successfully, but these errors were encountered: