ldc-developers / ldc

The LLVM-based D Compiler.
http://wiki.dlang.org/LDC
Other
1.22k stars 262 forks source link

Runtime error on synchronized(typeid(SomeInterface)) { } #1377

Closed puneet closed 8 years ago

puneet commented 8 years ago

Reduced testcase. Compiles with dmd. Tested with LDC master and merge-2.070. Both compile a binary that segfault when executed. synchronized(typeid(SomeClass)) { } works as expected.

// reduced testcase interface Foo { } void main() { synchronized(typeid(Foo)) { } }

JohanEngelen commented 8 years ago

Related DMD PR: https://github.com/D-Programming-Language/dmd/pull/5564 Note that in LDC, TypeInfo is immutable ("constant" in LLVM IR).

JohanEngelen commented 8 years ago

@puneet On my Mac with LLVM3.9, I can't get it to segfault. Can you give some more details?

puneet commented 8 years ago

$ ldc2 -v binary /home/puneet/local/github-ldc/ldc-master/build/bin/ldc2 version 028077 (DMD v2.069.2, LLVM 3.6.0) config /home/puneet/local/github-ldc/ldc-master/build/bin/ldc2.conf OVERVIEW: LDC - the LLVM D compiler [snip] $ cat typetest.d interface Foo {}

void main() { synchronized(typeid(Foo)) { // do nothing } } $ ldc2 -g typetest.d $ gdb typetest GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1 [snip] Reading symbols from typetest...done. (gdb) run Starting program: /tmp/typetest [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault. 0x0000000000409f43 in rt.monitor_.ensureMonitor() () (gdb) bt

0 0x0000000000409f43 in rt.monitor_.ensureMonitor() ()

1 0x000000000040a026 in _d_monitorenter ()

2 0x0000000000401f7b in D main () at typetest.d:5

3 0x0000000000405e6e in _d_run_main ()

4 0x0000000000402098 in main (argc=1, argv=0x7fffffffdd38) at .:7

(gdb)

puneet commented 8 years ago

$ uname -a Linux airavata 3.13.0-17-generic #37-Ubuntu SMP Mon Mar 10 21:44:01 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux $ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=14.04 DISTRIB_CODENAME=trusty DISTRIB_DESCRIPTION="Ubuntu 14.04.4 LTS"

JohanEngelen commented 8 years ago

See https://github.com/ldc-developers/ldc/issues/1358#issuecomment-200263499

redstar commented 8 years ago

Fixed in all branches.