[Issue 21025] New: Segfault for function contract -preview=dip1021

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 7 16:33:35 UTC 2020


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

          Issue ID: 21025
           Summary: Segfault for function contract -preview=dip1021
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: moonlightsentinel at disroot.org

The following code causes a segfault in DMD when compiled with
-preview=dip1021:

==================================
void uniq()(int[] r)
if (binaryFun(r, r)) {}

bool binaryFun(T, U)(T, U)
{
    return true;
}

void generateStatements()
{
    uniq([]);
}
==================================

gdb $DMD -batch -ex "run -c -o- -preview=dip1021" -ex bt

Program received signal SIGSEGV, Segmentation fault.
0x00000000083b93f4 in dmd.func.FuncDeclaration.setUnsafe() (this=0x0) at
dmd/func.d:1402
1402            if (flags & FUNCFLAG.safetyInprocess)

#0  0x00000000083b93f4 in dmd.func.FuncDeclaration.setUnsafe() (this=0x0) at
dmd/func.d:1402
#1  0x00000000083795ca in
_D3dmd6escape21checkMutableArgumentsFPSQBl6dscope5ScopeCQCc4func15FuncDeclarationCQDc5mtype12TypeFunctionCQEa10expression10ExpressionPSQFd4root5array__T5ArrayTQCcZQlbZ12checkOnePairMFmKSQHcQHbQGxFQGdQFoQErQDwQCxbZ8EscapeByKQBmCQIr11declaration14VarDeclarationQBhbZv
(__capture=0x7ffffffe9eb0, of=true, v2=0x7ffffdfb34c0, v=0x7ffffdfb34c0,
eb2=..., eb=..., i=0) at dmd/escape.d:167
#2  0x000000000837984b in
_D3dmd6escape21checkMutableArgumentsFPSQBl6dscope5ScopeCQCc4func15FuncDeclarationCQDc5mtype12TypeFunctionCQEa10expression10ExpressionPSQFd4root5array__T5ArrayTQCcZQlbZQGfMFmKSQGrQGqQGmFQFsQFdQEgQDlQCmbZ8EscapeBybZv
(__capture=0x7ffffffe9eb0, byval=true, eb=..., i=0) at dmd/escape.d:203
#3  0x0000000008379194 in
_D3dmd6escape21checkMutableArgumentsFPSQBl6dscope5ScopeCQCc4func15FuncDeclarationCQDc5mtype12TypeFunctionCQEa10expression10ExpressionPSQFd4root5array__T5ArrayTQCcZQlbZb
(gag=false, arguments=0x7ffffdfb3690, ethis=0x0, tf=0x8c2fa50,
fd=0x7ffffdfb4670, sc=0x7ffffdfb0930) at dmd/escape.d:210
#4  0x0000000008396948 in
_D3dmd13expressionsem18functionParametersFKxSQBr7globals3LocPSQCi6dscope5ScopeCQCz5mtype12TypeFunctionCQDx10expression10ExpressionCQEzQCa4TypePSQFm4root5array__T5ArrayTQCoZQlCQGr4func15FuncDeclarationPQCtPQDzZb
(peprefix=0x7ffffffeab70, prettype=0x7ffffdfb3610, fd=0x7ffffdfb4670,
arguments=0x7ffffdfb3690, tthis=0x0, ethis=0x0, tf=0x8c2fa50,
sc=0x7ffffdfb0930, loc=...) at dmd/expressionsem.d:2354
#5  0x000000000839f93a in ExpressionSemanticVisitor::visit(CallExp*)
(this=0x7ffffffeacf8, exp=0x7ffffdfb3600) at dmd/expressionsem.d:4999
#6  0x000000000838a3c2 in CallExp::accept(Visitor*) (this=0x7ffffdfb3600,
v=0x7ffffffeacf8) at dmd/expression.d:4975
#7  0x00000000083b3c84 in expressionSemantic(Expression*, Scope*)
(e=0x7ffffdfb3600, sc=0x7ffffdfb0930) at dmd/expressionsem.d:11497
#8  0x000000000847413a in
_D3dmd10staticcond19evalStaticConditionFPSQBo6dscope5ScopeCQCf10expression10ExpressionQBcJbPSQDn4root5array__T5ArrayTQChZQlZ4implMFQCvZb
(__capture=0x7ffffffeadd0, e=0x7ffffdfb3600) at dmd/staticcond.d:94
#9  0x0000000008473f90 in
_D3dmd10staticcond19evalStaticConditionFPSQBo6dscope5ScopeCQCf10expression10ExpressionQBcJbPSQDn4root5array__T5ArrayTQChZQlZb
(negatives=0x7fffff6c6790, errors=@0x7ffffffeaea8: false, e=0x7ffffdfb3600,
original=0x7fffff6c6510, sc=0x7ffffdfb0930) at dmd/staticcond.d:124
#10 0x000000000835fcbb in
_D3dmd9dtemplate19TemplateDeclaration18evaluateConstraintMFCQCgQCf16TemplateInstancePSQDg6dscope5ScopeQsPSQEa4root5array__T5ArrayTCQEzQz10rootobject10RootObjectZQBmCQGh4func15FuncDeclarationZb
(this=0x7fffff6c6660, fd=0x7ffffdfb3110, dedargs=0x7ffffdfb3000,
paramscope=0x7ffffdfb0620, sc=0x7ffffdfb0500, ti=0x7ffffdfb2e80) at
dmd/dtemplate.d:903
#11 0x0000000008363377 in
_D3dmd9dtemplate19TemplateDeclaration27deduceFunctionTemplateMatchMFCQCpQCo16TemplateInstancePSQDp6dscope5ScopeKCQEh4func15FuncDeclarationCQFh5mtype4TypePSQFx4root5array__T5ArrayTCQGw10expression10ExpressionZQBkZEQId7globals5MATCH
(this=0x7fffff6c6660, fargs=0x7fffff6c7540, tthis=0x0, fd=@0x7ffffffeb730:
0x7ffffdfb3110, sc=0x7ffffdfb0500, ti=0x7ffffdfb2e80) at dmd/dtemplate.d:2241
#12 0x0000000008365407 in
_D3dmd9dtemplate15functionResolveFKSQBi11declaration16MatchAccumulatorCQCr7dsymbol7DsymbolSQDl7globals3LocPSQEc6dscope5ScopePSQEu4root5array__T5ArrayTCQFtQz10rootobject10RootObjectZQBmCQHb5mtype4TypePSQHrQCxQCv__TQCsTCQIi10expression10ExpressionZQDzPPxaZ13applyTemplateMFCQKkQKj19TemplateDeclarationZi
(__capture=0x7ffffffeb940, td=0x7fffff6c6660) at dmd/dtemplate.d:2967
#13 0x00000000083658d8 in
_D3dmd9dtemplate15functionResolveFKSQBi11declaration16MatchAccumulatorCQCr7dsymbol7DsymbolSQDl7globals3LocPSQEc6dscope5ScopePSQEu4root5array__T5ArrayTCQFtQz10rootobject10RootObjectZQBmCQHb5mtype4TypePSQHrQCxQCv__TQCsTCQIi10expression10ExpressionZQDzPPxaZ10__lambda11MFQHqZi
(__capture=0x7ffffffeb940, s=0x7fffff6c6660) at dmd/dtemplate.d:3074
#14 0x00000000083bcbc8 in
_D3dmd4func13overloadApplyFCQBa7dsymbol7DsymbolMDFQxZiPSQCc6dscope5ScopeZi
(sc=0x7ffffdfb0500, dg=..., fstart=0x7fffff6c6660) at dmd/func.d:2696
#15 0x0000000008364197 in
_D3dmd9dtemplate15functionResolveFKSQBi11declaration16MatchAccumulatorCQCr7dsymbol7DsymbolSQDl7globals3LocPSQEc6dscope5ScopePSQEu4root5array__T5ArrayTCQFtQz10rootobject10RootObjectZQBmCQHb5mtype4TypePSQHrQCxQCv__TQCsTCQIi10expression10ExpressionZQDzPPxaZv
(pMessage=0x0, fargs=0x7fffff6c7540, tthis=0x0, tiargs=0x0, sc=0x7ffffdfb0500,
loc=..., dstart=0x7fffff6c6660, m=...) at dmd/dtemplate.d:3076
#16 0x00000000083bcf0b in
_D3dmd4func15resolveFuncCallFKxSQBe7globals3LocPSQBv6dscope5ScopeCQCm7dsymbol7DsymbolPSQDh4root5array__T5ArrayTCQEgQz10rootobject10RootObjectZQBmCQFo5mtype4TypePSQGeQCxQCv__TQCsTCQGv10expression10ExpressionZQDzEQIbQIa15FuncResolveFlagZCQJaQIz15FuncDeclaration
(flags=0 '\000', fargs=0x7fffff6c7540, tthis=0x0, tiargs=0x0, s=0x7fffff6c6660,
sc=0x7ffffdfb0500, loc=...) at dmd/func.d:2856
#17 0x000000000839eb39 in ExpressionSemanticVisitor::visit(CallExp*)
(this=0x7ffffffec4a8, exp=0x7fffff6c74e0) at dmd/expressionsem.d:4835
#18 0x000000000838a3c2 in CallExp::accept(Visitor*) (this=0x7fffff6c74e0,
v=0x7ffffffec4a8) at dmd/expression.d:4975
#19 0x00000000083b3c84 in expressionSemantic(Expression*, Scope*)
(e=0x7fffff6c74e0, sc=0x7ffffdfb0500) at dmd/expressionsem.d:11497
#20 0x0000000008462e3a in StatementSemanticVisitor::visit(ExpStatement*)
(this=0x7ffffffec578, s=0x7fffff6c75c0) at dmd/statementsem.d:186
#21 0x000000000845e8a6 in ExpStatement::accept(Visitor*) (this=0x7fffff6c75c0,
v=0x7ffffffec578) at dmd/statement.d:750
#22 0x0000000008462d24 in statementSemantic(Statement*, Scope*)
(s=0x7fffff6c75c0, sc=0x7ffffdfb0500) at dmd/statementsem.d:131
#23 0x00000000084630fc in StatementSemanticVisitor::visit(CompoundStatement*)
(this=0x7ffffffec8c8, cs=0x7fffff6c75f0) at dmd/statementsem.d:244
#24 0x000000000845f122 in CompoundStatement::accept(Visitor*)
(this=0x7fffff6c75f0, v=0x7ffffffec8c8) at dmd/statement.d:938
#25 0x0000000008462d24 in statementSemantic(Statement*, Scope*)
(s=0x7fffff6c75f0, sc=0x7ffffdfb0500) at dmd/statementsem.d:131
#26 0x0000000008458c0c in Semantic3Visitor::visit(FuncDeclaration*)
(this=0x7ffffffed3a0, funcdecl=0x7fffff6c71f0) at dmd/semantic3.d:575
#27 0x00000000083bc776 in FuncDeclaration::accept(Visitor*)
(this=0x7fffff6c71f0, v=0x7ffffffed3a0) at dmd/func.d:2558
#28 0x000000000845766e in semantic3(Dsymbol*, Scope*) (dsym=0x7fffff6c71f0,
sc=0x7ffffdfb01f0) at dmd/semantic3.d:81
#29 0x0000000008457a68 in Semantic3Visitor::visit(Module*)
(this=0x7ffffffed450, mod=0x7fffff6c4d20) at dmd/semantic3.d:194
#30 0x000000000832b93e in Module::accept(Visitor*) (this=0x7fffff6c4d20,
v=0x7ffffffed450) at dmd/dmodule.d:1462
#31 0x000000000845766e in semantic3(Dsymbol*, Scope*) (dsym=0x7fffff6c4d20,
sc=0x0) at dmd/semantic3.d:81
#32 0x000000000841138c in _D3dmd4mars7tryMainFmPPxaKSQz7globals5ParamZi
(params=..., argv=0x7ffffffee028, argc=5) at dmd/mars.d:597
#33 0x0000000008412a88 in D main (_param_0=...) at dmd/mars.d:952

--


More information about the Digitalmars-d-bugs mailing list