[Issue 21480] New: uncaught exceptions: stack trace truncated at NUL char

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 14 00:00:39 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=21480

          Issue ID: 21480
           Summary: uncaught exceptions: stack trace truncated at NUL char
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: kdevel at vogtner.de

from
http://forum.dlang.org/thread/ggyxirvvnypggstfkbzj@forum.dlang.org#post-ggyxirvvnypggstfkbzj:40forum.dlang.org

~~~char2.d
void main ()
{
   import std.stdio;
   import std.conv;
   char [2] win = [0, 'X'];
   auto ne = new Exception ("A " ~ win.to!string ~ " B");
   try throw ne;
   catch (Exception e)
      writeln ("exception caught: e.msg = <", e.msg, ">");
   throw ne;
}
~~~

Output:

exception caught: e.msg = <A X B>
object.Exception at char2.d(6): A              <--- truncated at \0
[...]

Commment from P.B.: This is definitely a bug. The problem is that the D runtime
uses `fprintf` to print the exception's error message, when it should be using
`fwrite`:

https://github.com/dlang/druntime/blob/v2.094.2/src/rt/dmain2.d#L733

--


More information about the Digitalmars-d-bugs mailing list