Bug 24431 – dmd -vcg-ast crashes printing failed template instantiation

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-03-06T18:16:41Z
Last change time
2024-11-16T23:27:08Z
Keywords
pull
Assigned to
No Owner
Creator
Dāvis

Comments

Comment #0 by davispuh — 2024-03-06T18:16:41Z
When I invoke $ dmd -vcg-ast program.d It crashes: Thread 1 (Thread 0x7ffff7c65d00 (LWP 2125794) "dmd"): #0 0x0000555555697457 in toCBuffer::DsymbolPrettyPrintVisitor::visit(FuncDeclaration*) () #1 0x000055555569a4ed in dmd.hdrgen.dumpTemplateInstance(dmd.dtemplate.TemplateInstance, ref dmd.common.outbuffer.OutBuffer, ref dmd.hdrgen.HdrGenState) () #2 0x0000555555699615 in toCBuffer::DsymbolPrettyPrintVisitor::visit(Module*) () #3 0x0000555555907cd9 in moduleToBuffer(OutBuffer&, bool, Module*) () #4 0x0000555555914e27 in dmd.main.tryMain(ulong, const(char)**, ref dmd.globals.Param) () #5 0x0000555555912501 in D main () Dump of assembler code for function toCBuffer::DsymbolPrettyPrintVisitor::visit(FuncDeclaration*): 0x0000555555697410 <+0>: push r15 0x0000555555697412 <+2>: push r14 0x0000555555697414 <+4>: push r13 0x0000555555697416 <+6>: push r12 0x0000555555697418 <+8>: push rbx 0x0000555555697419 <+9>: mov r14,rsi 0x000055555569741c <+12>: mov rbx,QWORD PTR [rdi+0x8] 0x0000555555697420 <+16>: mov rdi,QWORD PTR [rbx] 0x0000555555697423 <+19>: mov rsi,QWORD PTR [rsi+0x60] 0x0000555555697427 <+23>: call 0x5555556950c0 <dmd.hdrgen.stcToBuffer(ref dmd.common.outbuffer.OutBuffer, ulong)> 0x000055555569742c <+28>: test al,al 0x000055555569742e <+30>: je 0x55555569743d <toCBuffer::DsymbolPrettyPrintVisitor::visit(FuncDeclaration*)+45> 0x0000555555697430 <+32>: mov rdi,QWORD PTR [rbx] 0x0000555555697433 <+35>: mov esi,0x20 0x0000555555697438 <+40>: call 0x555555a232f0 <OutBuffer::writeByte(unsigned int)> 0x000055555569743d <+45>: mov r12,QWORD PTR [r14+0x8] 0x0000555555697441 <+49>: mov rax,QWORD PTR [r14+0x50] 0x0000555555697445 <+53>: xor r15d,r15d 0x0000555555697448 <+56>: cmp BYTE PTR [rax+0x8],0x5 0x000055555569744c <+60>: cmove r15,rax 0x0000555555697450 <+64>: mov r13,QWORD PTR [rbx] 0x0000555555697453 <+67>: mov r8,QWORD PTR [rbx+0x8] => 0x0000555555697457 <+71>: cmp BYTE PTR [r15+0x8],0x5 0x000055555569745c <+76>: jne 0x555555697475 <toCBuffer::DsymbolPrettyPrintVisitor::visit(FuncDeclaration*)+101> rax 0x7ffff79e5b10 140737347738384 rbx 0x7fffee01dcf0 140737186487536 rcx 0x6f747561 1869903201 rdx 0x4 4 rsi 0x20 32 rdi 0x7fffffffd240 140737488343616 rbp 0x555556e58f80 0x555556e58f80 rsp 0x7fffffffce60 0x7fffffffce60 r8 0x7fffffffcf40 140737488342848 r9 0x2 2 r10 0x0 0 r11 0x0 0 r12 0x7ffff738f8c0 140737341094080 r13 0x7fffffffd240 140737488343616 r14 0x7ffff10ae800 140737237411840 r15 0x0 0 <=== !!! rip 0x555555697457 0x555555697457 <toCBuffer::DsymbolPrettyPrintVisitor::visit(FuncDeclaration*)+71> eflags 0x10216 [ PF AF IF RF ] cs 0x33 51 ss 0x2b 43 ds 0x0 0 es 0x0 0 fs 0x0 0 gs 0x0 0 fs_base 0x7ffff7c65d00 140737350360320 gs_base 0x0 0 I'm on Arch Linux with DMD v2.107.0 I might try to provide reduced example program later at some point.
Comment #1 by razvan.nitu1305 — 2024-03-12T14:25:24Z
Unfortunately, there is little we can do to fix this if a test case is not provided. If you cannot reduce it, giving the full content of program.d still is better than nothing.
Comment #2 by davispuh — 2024-03-12T20:13:37Z
I narrowed it down to this: ``` import std.algorithm.iteration; void main() { splitter("test", '\n'); } ```
Comment #3 by dlang-bot — 2024-10-03T10:31:24Z
@dkorpel created dlang/dmd pull request #16916 "Fix bugzilla 24431 - dmd -vcg-ast crashes printing failed template in…" fixing this issue: - Fix bugzilla 24431 - dmd -vcg-ast crashes printing failed template instantiation https://github.com/dlang/dmd/pull/16916
Comment #4 by dlang-bot — 2024-10-03T23:47:15Z
dlang/dmd pull request #16916 "Fix bugzilla 24431 - dmd -vcg-ast crashes printing failed template in…" was merged into stable: - c7d7ad0fa8d99839103de49bfa59138940cc7746 by Dennis Korpel: Fix bugzilla 24431 - dmd -vcg-ast crashes printing failed template instantiation https://github.com/dlang/dmd/pull/16916
Comment #5 by dlang-bot — 2024-10-07T09:00:24Z
dlang/dmd pull request #16967 "Rebase stable6" was merged into master: - 7129068b0eb7d95aac4e17aced4262888da7bfe5 by Dennis: Fix bugzilla 24431 - dmd -vcg-ast crashes printing failed template in… (#16916) https://github.com/dlang/dmd/pull/16967
Comment #6 by dlang-bot — 2024-11-16T23:27:08Z
dlang/dmd pull request #17069 "Merge stable" was merged into master: - 3f48f53e2784c4bab812469f428eb65653035fcf by Dennis: Fix bugzilla 24431 - dmd -vcg-ast crashes printing failed template in… (#16916) https://github.com/dlang/dmd/pull/17069