digitalmars.D.bugs - [Issue 16212] New: Segfault using "with" for field access inside
- via Digitalmars-d-bugs (133/133) Jun 27 2016 https://issues.dlang.org/show_bug.cgi?id=16212
https://issues.dlang.org/show_bug.cgi?id=16212 Issue ID: 16212 Summary: Segfault using "with" for field access inside switch statement Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: regression Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: kirsybuu gmail.com struct S { int field; } void main() { S s = S(3); switch (1) with (s) { case 1: field = 555; // segfault break; default: break; } } Linux 64-bit DMD 2.071.0 and 2.070.0: $ dmd -g switchwithbug.d $ gdb switchwithbug (gdb) r Program received signal SIGSEGV, Segmentation fault. do_lookup_x (new_hash=new_hash entry=129119144, old_hash=old_hash entry=0x7fffffffdcf0, result=result entry=0x7fffffffdd00, scope=0x7fff0000022b, i=i entry=0, flags=flags entry=1, skip=skip entry=0x0, undef_map=undef_map entry=0x7ffff7ffe1c8) at dl-lookup.c:83 83 dl-lookup.c: No such file or directory. (gdb) bt old_hash=old_hash entry=0x7fffffffdcf0, result=result entry=0x7fffffffdd00, scope=0x7fff0000022b, i=i entry=0, flags=flags entry=1, skip=skip entry=0x0, undef_map=undef_map entry=0x7ffff7ffe1c8) at dl-lookup.c:83 undef_name=0x40cd71 "pthread_mutex_destroy", undef_map=0x7ffff7ffe1c8, ref=ref entry=0x7fffffffddb8, symbol_scope=0x7ffff7ffe520, version=0x7ffff7fd3b18, type_class=type_class entry=1, flags=1, skip_map=skip_map entry=0x0) at dl-lookup.c:737 reloc_arg=<optimized out>) at ../elf/dl-runtime.c:111 at ../sysdeps/x86_64/dl-trampoline.S:45 DMD 2.069.2 and 2.069.0: No issue! DMD 2.068.0, 2.067.1, 2.067.0, and even 2.065.0: Program received signal SIGSEGV, Segmentation fault. 0x000000000041d3b3 in D main () at switchwithbug.d:8 8 field = 555; Disassembly shows that "__withSym" hidden variable is not initialized: S s = S(3); 0x000000000041d3a8 <_Dmain+8>: movl $0x3,-0x10(%rbp) switch (1) with (s) { case 1: field = 555; 0x000000000041d3af <_Dmain+15>: mov -0x8(%rbp),%rax 0x000000000041d3b3 <_Dmain+19>: movl $0x22b,(%rax) break; 0x000000000041d3b9 <_Dmain+25>: xor %eax,%eax default: break; } } This bug isn't limited to DMD either, making me think it is a front-end issue: $ gdc --version gdc (crosstool-NG 1.20.0 - 20150405-2.066.1-f378f9ab41) 4.9.2 Program received signal SIGSEGV, Segmentation fault. strcmp () at ../sysdeps/x86_64/multiarch/../strcmp.S:132 132 ../sysdeps/x86_64/multiarch/../strcmp.S: No such file or directory. (gdb) bt old_hash=old_hash entry=0x7fffffffdb60, result=result entry=0x7fffffffdb70, scope=<optimized out>, i=<optimized out>, i entry=0, flags=flags entry=1, skip=skip entry=0x0, undef_map=undef_map entry=0x7ffff7ffe1c8) at dl-lookup.c:249 undef_map=0x7ffff7ffe1c8, ref=ref entry=0x7fffffffdc28, symbol_scope=0x7ffff7ffe520, version=0x7ffff7fd2030, type_class=type_class entry=1, flags=1, skip_map=skip_map entry=0x0) at dl-lookup.c:737 reloc_arg=<optimized out>) at ../elf/dl-runtime.c:111 at ../sysdeps/x86_64/dl-trampoline.S:45 at /home/build/tmp/build/.build/src/gcc-4.9.2/libphobos/libdruntime/gc/gc.d:3149 at /home/build/tmp/build/.build/src/gcc-4.9.2/libphobos/libdruntime/gc/gc.d:1433 ---Type <return> to continue, or q <return> to quit--- at /home/build/tmp/build/.build/src/gcc-4.9.2/libphobos/libdruntime/gc/gc.d:285 at /home/build/tmp/build/.build/src/gcc-4.9.2/libphobos/libdruntime/gc/proxy.d:148 at /home/build/tmp/build/.build/src/gcc-4.9.2/libphobos/libdruntime/rt/dmain2.d:195 at /home/build/tmp/build/.build/src/gcc-4.9.2/libphobos/libdruntime/rt/dmain2.d:415 this=this entry=0x7fffffffdda0, dg=...) at /home/build/tmp/build/.build/src/gcc-4.9.2/libphobos/libdruntime/rt/dmain2.d:386 mainFunc=<optimized out>) at /home/build/tmp/build/.build/src/gcc-4.9.2/libphobos/libdruntime/rt/dmain2.d:419 at /home/kirsybuu/x86_64-gdcproject-linux-gnu/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/include/d/__entrypoint.di:62 --
Jun 27 2016