www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17651] New: Segfult when parsing Ddoc ESCAPES macro

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

          Issue ID: 17651
           Summary: Segfult when parsing Ddoc ESCAPES macro
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: doob me.com

The following example results in a segmentation fault. Looking at the stack
trace it looks like it the segmentation fault occurs when parsing the ESCAPES
Ddoc macro:

$ cat foo.d
/**
Macros:
ESCAPES = /a/b/
*/
void foo() {}

$ lldb -- dmd foo.d -c -D
(lldb) target create "dmd"
Current executable set to 'dmd' (x86_64).
(lldb) settings set -- target.run-args  "foo.d" "-c" "-D"
(lldb) r
Process 1511 launched: '~/.dvm/compilers/dmd-2.075.0-b4/osx/bin/dmd' (x86_64)
Process 1511 stopped

dmd`DocComment::parseEscapes(Escape**, char const*, unsigned long) + 40, queue
= 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)

const*, unsigned long) + 40
dmd`DocComment::parseEscapes:
->  0x10009e6e0 <+40>: movq   (%rdi), %r12
    0x10009e6e3 <+43>: testq  %r12, %r12
    0x10009e6e6 <+46>: jne    0x10009e71c               ; <+100>
    0x10009e6e8 <+48>: movq   0x29db79(%rip), %rdi      ; (void
*)0x0000000100381898: D26TypeInfo_S4ddmd3doc6Escape6__initZ
(lldb) bt

dmd`DocComment::parseEscapes(Escape**, char const*, unsigned long) + 40, queue
= 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)

const*, unsigned long) + 40

char const*, unsigned long) + 351

Scope*, Array<Dsymbol*>*, OutBuffer*) + 37

Array<Dsymbol*>*, OutBuffer*) + 1420

Dsymbol*, char const*) + 3121

+ 93

OutBuffer*, Scope*) + 1193




dmd`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFNlZv + 40

dmd`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFNlMDFZvZv + 32

dmd`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFNlZv + 45

dmd`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFNlMDFZvZv + 32




The issue seems to occur on all versions of DMD. If I remove the ESCAPES macro
the segmentation fault does not occur.

--
Jul 14 2017