D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21592 - two stack traces if high surrogate is printed
Summary: two stack traces if high surrogate is printed
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other Other
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2021-01-29 20:33 UTC by kdevel
Modified: 2021-03-03 12:46 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kdevel 2021-01-29 20:33:13 UTC
```unpsur.d
import std.stdio: writeln;
import std.utf: byCodeUnit;

void main ()
{
   wstring w = "\U00010400";
   wchar wc = w.byCodeUnit [0]; // take high surrogate
   writeln (wc);                // let it throw a UTFException
}
```

Application output

std.utf.UTFException@std/stdio.d(2910): unpaired surrogate UTF-16 value
----------------
??:? @safe void std.stdio.File.LockingTextWriter.highSurrogateShouldBeEmpty() [0x5616f092907f]
/dlang/dmd/linux/bin64/../../src/phobos/std/stdio.d:2992 @safe void std.stdio.File.LockingTextWriter.put!(char).put(char) [0x5616f0922407]
/dlang/dmd/linux/bin64/../../src/phobos/std/range/primitives.d:277 @safe void std.range.primitives.doPut!(std.stdio.File.LockingTextWriter, char).doPut(ref std.stdio.File.LockingTextWriter, ref char) [0x5616f09223ea]
/dlang/dmd/linux/bin64/../../src/phobos/std/range/primitives.d:380 @safe void std.range.primitives.put!(std.stdio.File.LockingTextWriter, char).put(ref std.stdio.File.LockingTextWriter, char) [0x5616f09223bf]
/dlang/dmd/linux/bin64/../../src/phobos/std/stdio.d:1567 @safe void std.stdio.File.write!(wchar, char).write(wchar, char) [0x5616f0921bfe]
/dlang/dmd/linux/bin64/../../src/phobos/std/stdio.d:3911 @safe void std.stdio.writeln!(wchar).writeln(wchar) [0x5616f0921b82]
onlineapp.d:8 _Dmain [0x5616f0921736]
std.utf.UTFException@std/stdio.d(2910): unpaired surrogate UTF-16 value
----------------
??:? @safe void std.stdio.File.LockingTextWriter.highSurrogateShouldBeEmpty() [0x5616f092907f]
??:? @trusted void std.stdio.File.LockingTextWriter.__dtor() [0x5616f0929197]
??:? @trusted void std.stdio.File.LockingTextWriter.__aggrDtor() [0x5616f09291f0]
/dlang/dmd/linux/bin64/../../src/phobos/std/stdio.d:1541 @safe void std.stdio.File.write!(wchar, char).write(wchar, char) [0x5616f0921c1d]
/dlang/dmd/linux/bin64/../../src/phobos/std/stdio.d:3911 @safe void std.stdio.writeln!(wchar).writeln(wchar) [0x5616f0921b82]
onlineapp.d:8 _Dmain [0x5616f0921736]

expected: only one trace
Comment 1 Berni44 2021-02-15 19:38:29 UTC
The first trace is the expected one, the second trace is created, when the destructor is called.
Comment 2 Dlang Bot 2021-02-17 17:41:22 UTC
@aG0aep6G created dlang/phobos pull request #7801 "fix issue 21592 - two stack traces if high surrogate is printed" fixing this issue:

- fix issue 21592 - two stack traces if high surrogate is printed

https://github.com/dlang/phobos/pull/7801
Comment 3 Dlang Bot 2021-03-03 12:46:34 UTC
dlang/phobos pull request #7801 "fix issue 21592 - two stack traces if high surrogate is printed" was merged into master:

- 95acbbd658a62d4724abf5b3a53b26430a1bf312 by aG0aep6G:
  fix issue 21592 - two stack traces if high surrogate is printed

https://github.com/dlang/phobos/pull/7801