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

Closed
puneet opened this Issue Mar 22, 2016 · 6 comments

Comments

Projects
None yet
3 participants
@puneet

puneet commented Mar 22, 2016

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

This comment has been minimized.

Show comment
Hide comment
@JohanEngelen

JohanEngelen Mar 22, 2016

Member

Related DMD PR: dlang/dmd#5564
Note that in LDC, TypeInfo is immutable ("constant" in LLVM IR).

Member

JohanEngelen commented Mar 22, 2016

Related DMD PR: dlang/dmd#5564
Note that in LDC, TypeInfo is immutable ("constant" in LLVM IR).

@JohanEngelen

This comment has been minimized.

Show comment
Hide comment
@JohanEngelen

JohanEngelen Mar 22, 2016

Member

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

Member

JohanEngelen commented Mar 22, 2016

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

@puneet

This comment has been minimized.

Show comment
Hide comment
@puneet

puneet Mar 23, 2016

$ 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 Mar 23, 2016

$ 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

This comment has been minimized.

Show comment
Hide comment
@puneet

puneet Mar 23, 2016

$ 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"

puneet commented Mar 23, 2016

$ 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

This comment has been minimized.

Show comment
Hide comment
@redstar

This comment has been minimized.

Show comment
Hide comment
@redstar

redstar Mar 24, 2016

Member

Fixed in all branches.

Member

redstar commented Mar 24, 2016

Fixed in all branches.

@redstar redstar closed this Mar 24, 2016

JohanEngelen added a commit to JohanEngelen/ldc that referenced this issue May 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment