This must be my special day that everything I try gets broken.


import core.thread;
import std.stdio;

class ThreadTest{
        private core.thread.Thread th;

        public this() shared{
                th = cast( shared )(
                        new core.thread.Thread(
                                cast( void delegate() )( &threadRun )
                        )
                );
        }

        public void start() shared{
                (cast()th).start();
        }

        private void threadRun() shared{
                writeln("It works");
                readln();
        }
}


void main(){
        new shared ThreadTest().start();
        char[] abc = new char[4096];
}

=====

Run the program (Release or Debug doesn't matter).

- Mono Application Output -

[Thread debugging using libthread_db enabled]
Using host libthread_db library \"/lib/x86_64-linux-gnu/libthread_db.so.1\".
[New Thread 0x7ffff75ed700 (LWP 18480)]
[Switching to Thread 0x7ffff75ed700 (LWP 18480)]


In call stack, program comes to "__lll_lock_wait_private () in /build/buildd/eglibc-2.19/nptl/../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95", and
this locks everything.

Remove the "char[] abc = ne...." line, and everything is fine.
Remove the "new shared Thre..." line and everything is fine.

I don't want to blame dmd directly because as far as I see from the search I did with "__lll_lock_wait_private", some C++ programs are having same problem with malloc operation as well. But still, can this be because of compiler?

Reply via email to