[fpc-devel] porting fpc to Blue Gene/P: a cthreads bug
ppopov99 at gmail.com
Wed Jul 29 15:50:53 CEST 2009
I've been porting fpc 2.3.1 to a Blue Gene/P system (BG/P) and I hit a
bizarre bug in cthreads which I have no clue about. Needless to say, it
occurs only on the BG/P backend - this is the massivel parallel computing
part. To make the story short: these are thousands of powerpc chips which
run a "linux-like" stripped down kernel, no terminal in my case, debugging
is very limited.
Basically I figured how to create the posix thread right. However when the
thread function (ThreadMain) is about to return it calls
pthread_exit(...). Now this results in a failed assertation in gcc, signal
6 and a coredump.
I was able to trace it to the unwinding of the gcc exception handler for
the terminating thread. An obvious assertation fails (in unwind-dw2.c),
which means that some basic startup data of gcc is either 1) messed up 2)
So, I have two related questions:
1. Is the pthread_exit(...) call essential in ThreadMain?
2. This bug is either in the setup of some basic unit (system, initc,
basicunix, unix), or something in gcc needs to be initialized. Am I
What I've done so far is this (short story): I made a very simple example
in which pthread_create is called directly with very simple thread
function. It is along the lines of this
http://bugs.freepascal.org/view.php?id=14176 . This time however I removed
all I/O and no obvious threadvars. It runs fine on a regular linux-powerpc
and crashes on the BG/P computing nodes. I then compiled the function
which call pthread_create(...) along with the thread functions with gcc
and then linked against a pascal main function with fpc. The idea was to
have fpc start the main function and then execute the same code with gcc.
This one worked fine on BG/P. This makes me think initialization of GCC is
OK, e.g. cprt0.as is fine.
Could anyone suggest a good debugging strategy? I am wondering if it is
easy to generate a "bare bone" system unit which only makes the compiler
happy, no functions, no threadvars, etc. That is, nothing, except orderly
initialization of libc.
I will welcome any suggestions
More information about the fpc-devel