Porting GDC to QNX

Brad Roberts braddr at puremagic.com
Wed Mar 28 11:10:25 PDT 2007


On Wed, 28 Mar 2007, Sheff wrote:

> Hi everyone, I'm porting GDC compiler, version 0.23 and GCC 4.1.1 to QNX 
> Neutrino 6.3.0 SP1 (with GCC 3.3.5). The porting is almost done, GDC, 
> GCC and Phobos are compiled and working fine, but you can't say the same 
> for the programs, which GDC produces from D source code. So far I 
> tested, I only spot one problem: posix threads. Consider the following 
> example:

[snip code]

> When you run this program, it crashes with signal SIGUSR1, which's generated by pthread_join(), here's GDB output:
> 
> Program received signal SIGUSR1, User defined signal 1.
> [Switching to process 66433068]
> 0xb032f092 in ThreadJoin_r () from /usr/qnx630/target/qnx6/x86/lib/libc.so.2
> (gdb) bt
> #0  0xb032f092 in ThreadJoin_r ()
>    from /usr/qnx630/target/qnx6/x86/lib/libc.so.2
> #1  0xb031a801 in pthread_join ()
>    from /usr/qnx630/target/qnx6/x86/lib/libc.so.2
> Memory fault
> 
> But, if you'll replace the line:
> 
> const int num = 1_000_000;
> 
> with:
> 
> const int num = 100_000;
> 
> Then everything works fine, the "end" string gets printed, program successfuly exits. Consider another, similar example:

That's not a 'crash', that's receiving a signal.  The garbage collector 
uses SIGUSR1 and SIGUSR2 to stop and start the threads of the app around 
garbage collection.  You need to tell gdb to not stop when receiving them, 
or you need to just continue the app when they do come in if you care to 
see when collections are occurring.

(gdb) handle SIGUSR1 nostop
(gdb) handle SIGUSR2 nostop

(those commands are from memory, so check the docs if they're not right).

The reason you see it in the higher iterations and not the lower is simply 
that the higher one ends up doing a gc collection.

Later,
Brad



More information about the Digitalmars-d mailing list