Bug 24118 – ICE / regression from 2.103.1 - segfault on CTFE only code in 2.104.2 and 2.105.0

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2023-08-28T10:14:43Z
Last change time
2023-09-16T07:31:18Z
Keywords
industry, pull
Assigned to
No Owner
Creator
Paolo Invernizzi

Comments

Comment #0 by paolo.invernizzi — 2023-08-28T10:14:43Z
Platform Apple Silicon Reduced by dustmite from our internal codebase: ``` import std.algorithm : map; import std.range : zip; import std.typecons : tuple; void foo() { if( __ctfe ){ zip([1,2,3], ["a", "b", "c"]) .map!( i => tuple("", i[1]) ) .map!( a => a[0] ? a[0] : " " ~ a[1] ) ; } } ~/dlang/dmd-2.105.0/osx/bin/dmd src/api3.d zsh: illegal hardware instruction ``` If can help, with LDC the stack trace is: ``` 0 ldc2 0x00000001039df7e0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56 1 ldc2 0x00000001039de838 llvm::sys::RunSignalHandlers() + 72 2 ldc2 0x00000001039dfe34 SignalHandler(int) + 304 3 libsystem_platform.dylib 0x0000000185a9aa24 _sigtramp + 56 4 ldc2 0x0000000103d7e30c ToElemVisitor::visit(CondExp*) + 1540 5 ldc2 0x0000000103d7e30c ToElemVisitor::visit(CondExp*) + 1540 6 ldc2 0x0000000103d62fcc ToIRVisitor::visit(ReturnStatement*) + 996 7 ldc2 0x0000000103d6994c ToIRVisitor::visit(CompoundStatement*) + 304 8 ldc2 0x0000000103d2de7c DtoDefineFunction(FuncDeclaration*, bool) + 6244 9 ldc2 0x0000000103d1d7b4 CodegenVisitor::visit(TemplateInstance*) + 320 10 ldc2 0x0000000103d3ec84 codegenModule(IRState*, Module*) + 3108 11 ldc2 0x0000000103db250c ldc::CodeGenerator::emit(Module*) + 216 12 ldc2 0x0000000103dc7e40 codegenModules(Array<Module*>&) + 944 13 ldc2 0x0000000103ce156c mars_mainBody(Param&, Array<char const*>&, Array<char const*>&) + 1316 14 ldc2 0x0000000103f85b74 _D2rt6dmain212_d_run_main2UAAamPUQgZiZ6runAllMFZv + 116 15 ldc2 0x0000000103f85698 _d_run_main + 148 16 ldc2 0x0000000103dc4fcc main + 744 17 dyld 0x0000000185713f28 start + 2236 zsh: segmentation fault ~/dlang/ldc-1.34.0/bin/ldc2 src/api3.d ```
Comment #1 by maxhaton — 2023-09-05T13:56:19Z
Only apple silicon / Mac?
Comment #2 by paolo.invernizzi — 2023-09-05T14:06:24Z
It seems to crash also on linux, we don't have Windows machines to test.
Comment #3 by razvan.nitu1305 — 2023-09-05T14:50:29Z
Reduced code: void map(alias fun, T)(T[] arr) { fun(arr); } void foo() { if( __ctfe ) { ["a", "b", "c"].map!( a => " " ~ a[0] ); } }
Comment #4 by dlang-bot — 2023-09-06T10:49:26Z
@RazvanN7 updated dlang/dmd pull request #15578 "Issue 23874 - -profile=gc segfaults / ICE regression" fixing this issue: - Fix Issue 24118 - ICE / regression from 2.103.1 - segfault on CTFE only code in 2.104.2 and 2.105.0 https://github.com/dlang/dmd/pull/15578
Comment #5 by dlang-bot — 2023-09-11T11:29:05Z
dlang/dmd pull request #15578 "Issue 24118 - ICE / regression from 2.103.1 - segfault on CTFE only code in 2.104.2 and 2.105.0" was merged into stable: - 0f769730772bbd58f6f57549f391c88a554c7604 by RazvanN7: Fix Issue 24118 - ICE / regression from 2.103.1 - segfault on CTFE only code in 2.104.2 and 2.105.0 https://github.com/dlang/dmd/pull/15578
Comment #6 by dlang-bot — 2023-09-16T07:31:18Z
dlang/dmd pull request #15609 "merge stable" was merged into master: - 6bc17b01bb0c69660aeb55e0a914285a7afb27b0 by Razvan Nitu: Fix Issue 24118 - ICE / regression from 2.103.1 - segfault on CTFE only code in 2.104.2 and 2.105.0 (#15578) https://github.com/dlang/dmd/pull/15609