Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

puneet opened this issue Mar 22, 2016 · 6 comments

Comments

@puneet
Copy link
Contributor

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
Copy link
Member

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

@JohanEngelen
Copy link
Member

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

@puneet
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Member

See #1358 (comment)

@redstar
Copy link
Member

redstar commented Mar 24, 2016

Fixed in all branches.

@redstar redstar closed this as completed 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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants