www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Traceinfo gone

reply frame <frame86 live.com> writes:
I recently discovered that my exceptions do not show a trace 
anymore.
How can this happen?

```d
int main() {
   try {
     throw new Exception("test");
   } catch(Throwable e) {
     writefln("trace: %s", e.info);
   }
   // ...
}
```
I'm expecting something like this:
```
trace: 0x00402326
0x0040E337
0x0040E2B1
0x0040E14C
0x0040A1D2
0x0040236B
0x76466359 in BaseThreadInitThunk
0x77CA7B74 in RtlGetAppContainerNamedObjectPath
0x77CA7B44 in RtlGetAppContainerNamedObjectPath
```

but it just prints: "trace:" and continues normally (does not 
terminate).
The e.info contains a core.sys.windows.stacktrace.StackTrace but 
it seems empty.

I cannot reproduce it with a standalone example app - everything 
works as expected there. But not in my application. Anyone ever 
experienced this?
Jul 24
next sibling parent frame <frame86 live.com> writes:
On Saturday, 24 July 2021 at 08:41:20 UTC, frame wrote:

 I cannot reproduce it with a standalone example app
Meanwhile I can, it seems a linking problem or I'm doing something wrong? Please consider: ```d // dmd -m64 -L/DLL -version=lib test.d -of=common.dll // dmd -m64 test.d // test.d version (lib) { import core.sys.windows.dll; import std.stdio; mixin SimpleDllMain; export extern (C) void test() { writeln("test() called"); } } else { import std.stdio; pragma(lib, "common.lib"); extern (C) void test(); void main() { // No trace info anymore if extern function is called // test(); try { throw new Exception("test"); } catch (Throwable e) { writeln("trace: ", e.info); writeln("whatever"); } } } ```
Jul 24
prev sibling parent reply Adam D Ruppe <destructionator gmail.com> writes:
On Saturday, 24 July 2021 at 08:41:20 UTC, frame wrote:
 I recently discovered that my exceptions do not show a trace 
 anymore.
 How can this happen?
It needs to load the .pdb file at runtime, so make sure it stays next to your exe.
Jul 25
parent reply frame <frame86 live.com> writes:
On Sunday, 25 July 2021 at 10:26:34 UTC, Adam D Ruppe wrote:
 On Saturday, 24 July 2021 at 08:41:20 UTC, frame wrote:
 I recently discovered that my exceptions do not show a trace 
 anymore.
 How can this happen?
It needs to load the .pdb file at runtime, so make sure it stays next to your exe.
No, I think you misunderstand the issue. I don't care about the symbolic debug information. The issue is: w/o calling test() there are stack lines available but when I compile it with the test() call, no stack lines are available?
Jul 25
parent reply frame <frame86 live.com> writes:
On Sunday, 25 July 2021 at 11:17:26 UTC, frame wrote:

 The issue is: w/o calling test() there are stack lines 
 available but when I compile it with the test() call, no stack 
 lines are available?
So if my usage is valid I would file a bug report - but maybe my setup is just broken. Could some Windows user please verify this issue with static linked? ```d try { throw new Exception("test"); } catch (Throwable e) { const(char)[] lines; foreach (n; e.info) lines ~= n; assert(lines.length == 0); // true if test() call was compiled in } ```
Jul 26
parent frame <frame86 live.com> writes:
On Tuesday, 27 July 2021 at 05:14:22 UTC, frame wrote:
 On Sunday, 25 July 2021 at 11:17:26 UTC, frame wrote:
No further response to this, so I made a ticket: https://issues.dlang.org/show_bug.cgi?id=22181
Aug 05