Open thelastmammoth opened 12 years ago
Also on Linux64.
I submitted a pull request https://github.com/ldc-developers/druntime/pull/18 that fixes this issue.
I get a stack trace now but the symbols are still missing (compiled with -g):
core.exception.AssertError@main4.d(3): Assertion failure
----------------
./main4() [0x401ddc]
./main4() [0x401e02]
./main4() [0x40f194]
./main4() [0x40f069]
./main4() [0x40f105]
./main4() [0x40f069]
./main4() [0x40efc8]
./main4() [0x401f28]
/lib64/libc.so.6(__libc_start_main+0xf5) [0x7f66b960edc5]
Do you have an idea why?
Not really sure why. I tested on OS X -- the stack trace looks fine (if app is compiled with -g). I'll check on Linux x86_64.
By the way, does LDC generated code ever show the stack trace? It might be easier to debug this if there's an example of successful stack trace dumping. Unrelated question: how do you validate pull requests to druntime? It doesn't look like there's an automated travis-ci job triggered for these PRs.
Up to now, I only got a stack trace on Win64 with ldc2 compiled code. IMHO it can be only a stupid problem like the one you fixed. DMD and LDC use Dwarf on Linux.
I validated the PR manually. Fore more complex PRs I create a branch in druntime and ldc to trigger the Travis build.
On Linux the symbols are missing for me too. I'll have to check how TraceInfo.toString() is implemented, to figure why the symbols are missing. This is a related issue, but not really about stack not being dumped on assert. I'm not sure -- perhaps, this issue could be closed, and another to be opened (or this one renamed) for the remaining problem.
I think this is a good idea. I opened #863 for the new problem.
Just tested this and: the problem is back.
(tested on OS X, 0.17.2, 1.0.0, and 1.1.0 do not show stack traces)
Another testcase (use dmd -run test.d
):
import std.json;
import std.stdio;
string pjson(ref JSONValue js)
{
return js["hhh"].str;
}
void main()
{
JSONValue js;
js["hh"] = 10;
try{
pjson(js);
} catch(Exception e){
writeln(e.toString());
}
}
It may have something to do with the frame pointer (register EBP/RBP) not always being used/set up (gcc -fomit-frame-pointer
); just tested on Win64, where the stack trace is also missing for your example. The unoptimized Win64 ASM for
int main()
{
int a = 0;
writefln("Hello LDC2");
return a;
}
doesn't use RBP at all. Just a guess of mine based on https://github.com/ldc-developers/druntime/blob/ldc/src/core/runtime.d#L522, plus the etc.linux.memoryerror
failures seemed to suggest something wrong with RBP too.
Did we ever end up merging https://github.com/weka-io/druntime/commits/9b4a3c05 into mainline LDC? That should make backtraces much reliable.
Nope ;) - are you going to merge or shall I?
Please do. ;) My time budget to spend on LDC right now is far in the negative figures.
:] Alright. Btw I just figured the frame-pointer optimization can be disabled via -disable-fp-elim
; I didn't expect it to be enabled by default for non-optimized and even debug builds.
FP elim in debug builds makes little sense – if that is indeed what is happening, I'd say it is a bug.
Reopening so we won't forget to add a testcase.
I think that -disable-fp-elim
should be implicit in -O0
builds, perhaps disabled from -O1
(GCC behavior https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Optimize-Options.html).
Note that the complete backtrace already shows up in debuggers (tested with lldb
) when the test is compiled with only -g
and breaking on _d_assert
.
Oh this isn't fixed at all; the commit message said this doesn't fix #115
- too elaborate for GitHub's AI. ;)
(it's kindof fixed on OSX with -disable-fp-elim
! So we are closer. )
Update:
-disable-fp-elim
, which should be implicit for debug builds. I had a very quick look a while back and IIRC I didn't find anything in the LDC source, so it appeared to be the LLVM default. Peeking at clang code may help.--export-dynamic
as backtrace_symbols()
doesn't read from debuginfos. Known upstream and partially fixed as DMD issue 11870 (which is marked as resolved); DMD uses -L--export-dynamic
in its default config file.The original issue will be fixed with #2097 (macOS assertions). We should probably open a number of more concrete tickets for the remaining issues (e.g. #2098, #2099).
the stack trace appears in dmd, not ldmd2/ldc (even with various combination of debug flags): (i'm on osx if that's relevant).
main4.d:
==> no stack trace