-
-
Notifications
You must be signed in to change notification settings - Fork 267
Exception stack traces on macOS/iOS are in a bad state #4895
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
Comments
This can hardly be the general case, as macOS CI includes backtrace tests and is happy on both x86_64 and arm64. So at least some aspects of this seem specific to your setup. Are you talking about unoptimized The Are you talking about distributed binaries, where e.g. the .dSYM files might be missing? [Note that I don't have any Apple stuff and cannot test anything myself.] Ref: #4006 |
I've tested with and without Snippet used for testing: void foo(int i)
{
if (i > 0)
foo(i - 1);
else assert(false);
}
void bar()
{
foo(4);
}
void main()
{
bar();
} macOS 15.3.1 arm64, latest Xcode, LDC 1.40.1 - same result for
With
Compiling for x64 (
I'm also getting the same result when compiling natively on an Intel Mac, both for macOS 15.3 and macOS 10.15. Running However, compiling with LDC 1.31.0 for x64 results in a stack trace comparable to arm64:
Interestingly, for LDC 1.31.0 on x64, line numbers are getting displayed correctly after
The excessive CPU use of the |
As said above, you need an additional Then my understanding is that Apple's ld64 linker at one point decided not to keep the With AFAIU, running |
Just now I did some testing on my macbook (macOS Sonoma 14.6.1 arm64), with LDC 1.40.1 and got different results for the testsnippet given above. All results are as expected except for no line number with The first post contains a number of separate items without clear testcase or actionable items, so I don't know what to do with those. I never had issues with |
The only part from Druntime should be W.r.t. However, the x86-64 build is only showing a single frame, regardless of Regarding |
Btw guys, what is that .dSYM bundle? From the linked stackoverflow post:
Does this mean that running |
From what I can see, the original binary stays untouched. The dSYM output is a special folder (bundle) that contains one or more files with DWARF debug information, as well as separate address relocation data as YAML files. |
Unfortunately, |
No, If the implementation can be sped up, that should be done upstream, even if DMD can work around this performance issue.
Ah too bad, so we do need |
Yeah, from everything I can find, it looks like Another possible improvement would be to cache the results of |
Yeah I see the same single frame issue here. |
As long as macOS has used DWARF the linker has stripped all debug info. You can see my comment how this works on macOS: https://github.com/dlang/dmd/blob/605fb8bf5b522f197798ab4a5197883a7fb0c964/compiler/src/dmd/backend/dwarfdbginf.d#L16-L27 |
We can implement whatever |
Can you be more specific on "everything else"? I am personally quite opposed to implementing (and maintaining!!!!!!) things ourselves that already have implementations elsewhere. I feel that there is already too much work for our available resources. |
|
:) when I see this list, I see a huge confirmation of my point that it is very bad idea to implement things ourselves. Build tool, librarian and linker, are all very bad when compared to alternatives. Compiler, runtime, and stdlib cannot be avoided when making a new language, and all are sub-par perhaps partly due to the effort spent on the rest... Even for the compiler, "outsourcing" codegen to LLVM (or GCC) is a huge win in quality, performance, and platform support. Back on topic: implementing |
Well there you go 😉. Seems like [1] https://llvm.org/doxygen/classllvm_1_1symbolize_1_1LLVMSymbolizer.html |
Just noticed another issue - the |
One thing I could easily do is restoring the
Is that still the case with v1.41.0-beta1 and its kept frame pointers? |
|
Okay as expected, and if you had tested |
@kinke I actually did and it didn't make a difference for x86-64. But can you explain why the stack walking the top frames would be affected by DRuntime code when that only occurs in the lower stack frames? |
That doesn't make a lot of sense - with
I think it starts from the top (innermost) frames, which are in druntime ( |
Hm, of course, I completely forgot about the exception related code that precedes the actual stack walking invocation. I don't think I used |
At least since the change to use "atos" for resolving stack frames, the state of printing call stacks is pretty disastrous on macOS, regardless of the
-g
switch:Printing an exception stack trace will freeze the calling thread for an extended period of time (can be a few hundred ms), which means that a process that logs/prints a larger number of exceptions can easily become unusable or would be a very easy DDoS target.
For x86-64 builds in particular, the stack unwinding functionality appears to be broken and only the topmost stack frame is being displayed.
Resolving file names and line numbers doesn't seem to work at all.
Stack traces generated for system crash reports usually stop at the first
extern (D)
function (I'm not sure whether this might be a simple issue of--frame-pointer
, I'll have to check whether that makes a difference)On some systems
atos
isn't available at allIn comparison, dmd appears to work fine (stack traces with symbols working regardless and file/line number working correctly when passing
-g
.This has been an issue that wanted to dig deeper into for a while now, but never really got to it, so I just wanted to at least get this written down to maybe start a discussion.
The text was updated successfully, but these errors were encountered: