Bug 24512 – DMD writeln with malloc allocated slice crashes lld

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2024-04-19T15:55:51Z
Last change time
2024-12-13T19:34:47Z
Assigned to
No Owner
Creator
Marcelo Silva Nascimento Mancini
Moved to GitHub: dmd#20443 →

Comments

Comment #0 by msnmancini — 2024-04-19T15:55:51Z
```d void main() { import core.stdc.stdlib; import std.stdio; char[] s = (cast(char*)malloc(64))[0..64]; s[] = 'a'; writeln(s); s[] = 'b'; writeln(s); } ``` Having support for lld linker would be actually nice since one would be able to have a faster linker support for DMD.
Comment #1 by destructionator — 2024-04-19T16:00:11Z
works for me... what exactly are you doing and seeing?
Comment #2 by msnmancini — 2024-04-19T16:05:23Z
`dmd -g -debug -run app.d` When running with Visual Studio: ``` Exception thrown at 0x00000001401173B0 in app.exe: 0xC0000005: Access violation executing location 0x00000001401173B0. ``` > app.exe!00000001401173b0() Unknown > app.exe!_msvc_fputc_nolock() Unknown > app.exe!std.stdio.File.LockingTextWriter.put!char.put(char this) Line 3232 Unknown > app.exe!std.stdio.writeln!(char[]).writeln(char[] __param_0) Line 4272 Unknown ``` This is where it crashes ``` if (orientation_ <= 0) trustedFPUTC(c, handle_); ```
Comment #3 by msnmancini — 2024-04-19T16:08:41Z
Also, I'm using dmd v2.108.0
Comment #4 by robert.schadek — 2024-12-13T19:34:47Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20443 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB