[Issue 18334] New: Segfault on FuncExp::matchType while trying to compile invalid .d file

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 30 10:20:57 UTC 2018


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

          Issue ID: 18334
           Summary: Segfault on FuncExp::matchType while trying to compile
                    invalid .d file
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: tetyys at tetyys.com

Following invalid vibe.d program causes a crash on dmd v2.078.1 (vibe.d
0.8.3-alpha.2, vibe-core 1.4.0-alpha.1, stdx-allocator 2.77.0, eventcore
0.8.27, taggedalgebraic 0.10.9):

import vibe.vibe;
void main()
{
    auto router = URLRouter;
    router.registerWebInterface(new WebService);
}

class WebService
{
    struct C {
    }

    enum d ;

    @d
    a(C a)
    {
    }

    void b()
    {
    }

}

Results in:
source/app.d(4,16): Error: type URLRouter has no value
../../.dub/packages/vibe-d-0.8.3-alpha.2/vibe-d/utils/vibe/internal/meta/funcattr.d(313,83):
Error: type d is not an expression
/usr/include/dmd/phobos/std/meta.d(915,20): Error: template instance
vibe.internal.meta.funcattr.pred!(d) error instantiating
../../.dub/packages/vibe-d-0.8.3-alpha.2/vibe-d/utils/vibe/internal/meta/funcattr.d(378,30):
       instantiated from here: Filter!(isInputAttribute, d)
../../.dub/packages/vibe-d-0.8.3-alpha.2/vibe-d/utils/vibe/internal/meta/funcattr.d(134,16):
       instantiated from here: AttributedParameterMetadata!(a)
../../.dub/packages/vibe-d-0.8.3-alpha.2/vibe-d/web/vibe/web/web.d(899,22):    
   instantiated from here: IsAttributedParameter!(a, "a")
../../.dub/packages/vibe-d-0.8.3-alpha.2/vibe-d/web/vibe/web/web.d(185,34):    
   instantiated from here: handleRequest!("a", a, WebService)
source/app.d(5,29):        instantiated from here:
registerWebInterface!(WebService, cast(MethodStyle)5)
Segmentation fault
/usr/bin/dmd failed with exit code 139.


Stack trace:

#0  0x00000000005f742a in FuncExp::matchType(Type*, Scope*, FuncExp**, int) ()
#1  0x000000000055e9a0 in implicitConvTo::ImplicitConvTo::visit(FuncExp*) ()
#2  0x00000000005f7751 in FuncExp::accept(Visitor*) ()
#3  0x000000000055cadd in implicitConvTo(Expression*, Type*) ()
#4  0x00000000006a2201 in TypeFunction::callMatch(Type*, Array<Expression*>*,
int) ()
#5  0x00000000005d6c0b in dmd.dtemplate.functionResolve(dmd.declaration.Match*,
dmd.dsymbol.Dsymbol, dmd.globals.Loc, dmd.dscope.Scope*,
dmd.root.array.Array!(dmd.root.rootobject.RootObject).Array*, dmd.mtype.Type,
dmd.root.array.Array!(dmd.expression.Expression).Array*).applyFunction(dmd.func.FuncDeclaration)
()
#6  0x00000000005d7d29 in dmd.dtemplate.functionResolve(dmd.declaration.Match*,
dmd.dsymbol.Dsymbol, dmd.globals.Loc, dmd.dscope.Scope*,
dmd.root.array.Array!(dmd.root.rootobject.RootObject).Array*, dmd.mtype.Type,
dmd.root.array.Array!(dmd.expression.Expression).Array*).__lambda10(dmd.dsymbol.Dsymbol)
()
#7  0x000000000062b768 in dmd.func.overloadApply(dmd.dsymbol.Dsymbol, scope
int(dmd.dsymbol.Dsymbol) delegate) ()
#8  0x00000000005d675a in dmd.dtemplate.functionResolve(dmd.declaration.Match*,
dmd.dsymbol.Dsymbol, dmd.globals.Loc, dmd.dscope.Scope*,
dmd.root.array.Array!(dmd.root.rootobject.RootObject).Array*, dmd.mtype.Type,
dmd.root.array.Array!(dmd.expression.Expression).Array*) ()
#9  0x000000000062c03f in resolveFuncCall(Loc, Scope*, Dsymbol*,
Array<RootObject*>*, Type*, Array<Expression*>*, int) ()
#10 0x00000000006099a7 in ExpressionSemanticVisitor::visit(CallExp*) ()
#11 0x00000000005f9e79 in CallExp::accept(Visitor*) ()
#12 0x0000000000709e84 in StatementSemanticVisitor::visit(ExpStatement*) ()
#13 0x00000000006f210d in ExpStatement::accept(Visitor*) ()
#14 0x000000000070a314 in StatementSemanticVisitor::visit(CompoundStatement*)
()
#15 0x00000000006f2e59 in CompoundStatement::accept(Visitor*) ()
#16 0x000000000070b9d2 in StatementSemanticVisitor::visit(ScopeStatement*) ()
#17 0x00000000006f3401 in ScopeStatement::accept(Visitor*) ()
#18 0x000000000070b63f in
StatementSemanticVisitor::visit(UnrolledLoopStatement*) ()
#19 0x00000000006f32a1 in UnrolledLoopStatement::accept(Visitor*) ()
#20 0x000000000070d1c4 in StatementSemanticVisitor::visit(ForeachStatement*) ()
#21 0x00000000006f3eb5 in ForeachStatement::accept(Visitor*) ()
#22 0x000000000070a314 in StatementSemanticVisitor::visit(CompoundStatement*)
()
#23 0x00000000006f2e59 in CompoundStatement::accept(Visitor*) ()
#24 0x000000000070b9d2 in StatementSemanticVisitor::visit(ScopeStatement*) ()
#25 0x00000000006f3401 in ScopeStatement::accept(Visitor*) ()
#26 0x000000000070b63f in
StatementSemanticVisitor::visit(UnrolledLoopStatement*) ()
#27 0x00000000006f32a1 in UnrolledLoopStatement::accept(Visitor*) ()
#28 0x000000000070d1c4 in StatementSemanticVisitor::visit(ForeachStatement*) ()
#29 0x00000000006f3eb5 in ForeachStatement::accept(Visitor*) ()
#30 0x000000000070a314 in StatementSemanticVisitor::visit(CompoundStatement*)
()
#31 0x00000000006f2e59 in CompoundStatement::accept(Visitor*) ()
#32 0x00000000005b11d6 in Semantic3Visitor::visit(FuncDeclaration*) ()
#33 0x000000000062b30d in FuncDeclaration::accept(Visitor*) ()
#34 0x00000000005af085 in Semantic3Visitor::visit(TemplateInstance*) ()
#35 0x00000000005e41ad in TemplateInstance::accept(Visitor*) ()
#36 0x00000000005e4175 in TemplateInstance::trySemantic3(Scope*) ()
#37 0x00000000005ccdaf in
dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance,
dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*) ()
#38 0x00000000005d67e2 in dmd.dtemplate.functionResolve(dmd.declaration.Match*,
dmd.dsymbol.Dsymbol, dmd.globals.Loc, dmd.dscope.Scope*,
dmd.root.array.Array!(dmd.root.rootobject.RootObject).Array*, dmd.mtype.Type,
dmd.root.array.Array!(dmd.expression.Expression).Array*) ()
#39 0x000000000062c03f in resolveFuncCall(Loc, Scope*, Dsymbol*,
Array<RootObject*>*, Type*, Array<Expression*>*, int) ()
#40 0x000000000060ace3 in ExpressionSemanticVisitor::visit(CallExp*) ()
#41 0x00000000005f9e79 in CallExp::accept(Visitor*) ()
#42 0x0000000000709e84 in StatementSemanticVisitor::visit(ExpStatement*) ()
#43 0x00000000006f210d in ExpStatement::accept(Visitor*) ()
#44 0x000000000070a314 in StatementSemanticVisitor::visit(CompoundStatement*)
()
#45 0x00000000006f2e59 in CompoundStatement::accept(Visitor*) ()
#46 0x00000000005b11d6 in Semantic3Visitor::visit(FuncDeclaration*) ()
#47 0x000000000062b30d in FuncDeclaration::accept(Visitor*) ()
#48 0x00000000005af7ee in Semantic3Visitor::visit(Module*) ()
#49 0x0000000000594785 in Module::accept(Visitor*) ()
#50 0x000000000068faec in dmd.mars.tryMain(ulong, const(char)**) ()

   0x00000000005f73f2 <+1338>:  pop    %rbp
   0x00000000005f73f3 <+1339>:  retq
   0x00000000005f73f4 <+1340>:  mov    0x28(%rdx),%rsi
   0x00000000005f73f8 <+1344>:  mov    0x70(%rsi),%rbx
   0x00000000005f73fc <+1348>:  mov    0x18(%rdx),%rax
   0x00000000005f7400 <+1352>:  rex movzbl 0x8(%rax),%edi
   0x00000000005f7405 <+1357>:  cmp    0x8(%r13),%dil
   0x00000000005f7409 <+1361>:  setne  %cl
   0x00000000005f740c <+1364>:  mov    %cl,-0x30(%rbp)
   0x00000000005f740f <+1367>:  cmpb   $0x0,0x1b8(%rsi)
   0x00000000005f7416 <+1374>:  je     0x5f74ee
<_ZN7FuncExp9matchTypeEP4TypeP5ScopePPS_i+1590>
   0x00000000005f741c <+1380>:  mov    0x80(%r15),%rsi
   0x00000000005f7423 <+1387>:  mov    0x80(%rbx),%rdi
=> 0x00000000005f742a <+1394>:  mov    (%rdi),%rax
   0x00000000005f742d <+1397>:  rex.W callq *0x118(%rax)
   0x00000000005f7434 <+1404>:  cmp    $0x1,%eax
   0x00000000005f7437 <+1407>:  jne    0x5f74ee
<_ZN7FuncExp9matchTypeEP4TypeP5ScopePPS_i+1590>
   0x00000000005f743d <+1413>:  movb   $0x1,-0x30(%rbp)
   0x00000000005f7441 <+1417>:  mov    0x4b1270(%rip),%rdi        # 0xaa86b8
   0x00000000005f7448 <+1424>:  callq  0x7e6798 <_d_newclass>
   0x00000000005f744d <+1429>:  mov    %rax,%r14
   0x00000000005f7450 <+1432>:  mov    0x88(%rbx),%r9
   0x00000000005f7457 <+1439>:  mov    0x80(%r15),%r8
   0x00000000005f745e <+1446>:  mov    0x90(%rbx),%ecx
   0x00000000005f7464 <+1452>:  mov    0x9c(%rbx),%edx
   0x00000000005f746a <+1458>:  xor    %esi,%esi
   0x00000000005f746c <+1460>:  mov    %r14,%rdi
   0x00000000005f746f <+1463>:  callq  0x6a0fec
<_D3dmd5mtype12TypeFunction6__ctorMFPS3dmd4root5array32__T5ArrayTC3dmd5mtype9ParameterZ5ArrayC3dmd5mtype4TypeiE3dmd7globals4LINKmZC3dmd5mtype12TypeFunction>

--


More information about the Digitalmars-d-bugs mailing list