Thread overview
Segfault in DMD OSX
Sep 22, 2014
Etienne
Sep 22, 2014
Etienne
Sep 22, 2014
Etienne
September 22, 2014
I'm having issues with DMD returning exit code -11 rather than compiling my project. I have no idea how to debug this, I'm using Mac OS X 10.9.4 with latest git DMD tagged 2.066, and this project:

https://github.com/etcimon/event.d

When I hit `dub run`, I get the exit code. Not sure why or where the problem comes from, I can't get GDB to run on the mac (something about Mach task port error in gdb), and dmd DEBUG gives no additional info. Any ideas?
September 22, 2014
I managed to get gdb running, here's what I get:

Starting program: /bin/dmd -lib -m64 -g source/event/internals/epoll.d source/event/internals/kqueue.d source/event/internals/path.d source/event/internals/validator.d source/event/internals/hashmap.d source/event/internals/memory.d source/event/internals/socket_compat.d source/event/internals/win32.d source/event/file.d source/event/tcp.d source/event/timer.d source/event/watcher.d source/event/dns.d source/event/types.d source/event/windows.d source/event/events.d source/event/notifier.d source/event/signal.d source/event/threads.d source/event/udp.d source/event/d.d source/event/posix2.d source/event/posix.d source/event/test.d
Using FreeBSD KQueue for events

Program received signal SIGSEGV, Segmentation fault.
0x00000001000d818b in TemplateInstance::findBestMatch(Scope*, Array<Expression*>*) ()
(gdb) show registers
Undefined show command: "registers". Try "help show".
(gdb) registers
Undefined command: "registers". Try "help".
(gdb) info registers
rax 0x1093fb750 4450137936
rbx 0x0 0
rcx 0x0 0
rdx 0x7fff5fbfebf0 140734799801328
rsi 0x12048d950 4836612432
rdi 0x0 0
rbp 0x7fff5fbfed60 0x7fff5fbfed60
rsp 0x7fff5fbfecb0 0x7fff5fbfecb0
r8 0x106117660 4396775008
r9 0x7fff5fbfed00 140734799801600
r10 0x7fff5fbfed00 140734799801600
r11 0x1a340b60 439618400
r12 0x0 0
r13 0x1001b14cf 4296742095
r14 0x0 0
r15 0x101a34050 4322443344
rip 0x1000d818b 0x1000d818b <TemplateInstance::findBestMatch(Scope*, Array<Expression*>*)+1339>
eflags 0x10246 [ PF ZF IF RF ]
cs 0x2b 43
ss <unavailable>
ds <unavailable>
es <unavailable>
fs 0x0 0
gs 0x93f0000 155123712
(gdb)

On 2014-09-22 12:35 PM, Etienne wrote:
> I'm having issues with DMD returning exit code -11 rather than compiling
> my project. I have no idea how to debug this, I'm using Mac OS X 10.9.4
> with latest git DMD tagged 2.066, and this project:
>
> https://github.com/etcimon/event.d
>
> When I hit `dub run`, I get the exit code. Not sure why or where the
> problem comes from, I can't get GDB to run on the mac (something about
> Mach task port error in gdb), and dmd DEBUG gives no additional info.
> Any ideas?

September 22, 2014
Here's with debug symbols in DMD

Program received signal SIGSEGV, Segmentation fault.
0x000000010013c4d0 in TemplateInstance::findBestMatch (this=0x101c34050, sc=0x12058d740, fargs=0x0) at template.c:7329
7329 tempdecl->kind(), tempdecl->parent->toPrettyChars(), tempdecl->ident->toChars());
(gdb) print havetempdecl
$1 = false
(gdb) print tempdecl->kind()
$2 = 0x100290149 "overload alias"
(gdb) print tempdecl->parent->toPrettyChars()
Cannot access memory at address 0x0
(gdb) print tempdecl->ident->toChars()
$3 = 0x100515bd8 "Array"
(gdb) print tempdel->parent
No symbol "tempdel" in current context.
(gdb) print tempdecl->parent
$4 = (Dsymbol *) 0x0
(gdb) print tempdecl
$5 = (Dsymbol *) 0x1095fbc50
(gdb)

The tempdecl->parent is being accessed even though it may be null in :7329 :
  ::error(loc, "%s %s.%s does not match any template declaration",
tempdecl->kind(), tempdecl->parent->toPrettyChars(), tempdecl->ident->toChars());