"Hello World" program core dumps with GHC 4.08.1 on HPUX 10.2
0
BENNETT,ANDY (HP-Unitedkingdom,ex1)
andy_bennett at hp.com
Thu Feb 8 11:19:30 EST 2001
Hello again,
I've managed to get ghc working on my HP-UX box, and I thought I'd share my
solution in case there is no better remedy available and someone else
encounters the same problem. I'd be interested to know how the build to
generate the hsc executable in the distribution download gets around the
problem. Anyway, as I indicated in my last mail, the C compiler behind ghc
seems to generate function pointers that point into a Procedure Label Table
(PLT) containing the real code address. So, I modified the HP bit of the
TailCalls.h header file to:
#ifdef hppa1_1_hp_hpux_TARGET
#define JMP_(cont) \
do { void *_procedure = (void *)(cont); \
if (((int) _procedure) & 2) \
_procedure = (void *)(*((int *) (_procedure - 2))); \
goto *_procedure; \
} while(0)
#endif /* hppa1_1_hp_hpux_TARGET */
The 'if' statement is my bit. It basically checks the procedure label flag
and dereferences the true value if necessary. It costs 2 extra machine
instructions per use of the JMP_ macro, the overall performance cost of
which I am unsure.
Regards,
Andy Bennett.
> -----Original Message-----
> Sent: 05 February 2001 01:03
> To: 'glasgow-haskell-bugs at haskell.org'
> Subject: "Hello World" program core dumps with GHC 4.08.1 on
> HPUX 10.20
>
>
> Hello,
>
> I'm not sure whether I'm doing something wrong, but I've just
> downloaded the
> HPUX 4.08.1 binary distribution of GHC and have installed it
> with GCC 2.95.2
> (downloaded from HPUX porting site) along side it. I'm
> running these on HPUX
> 10.20.
>
> When I try the "Hello, world!" example program from the
> install guide, it
> compiles okay, but on running it does the following:
>
> $ cat Main.hs
> main = putStr "Hello, world!\n"
> $ ghc -o hello Main.hs
> $ ./hello
> Memory fault(coredump)
> $
>
> Hopefully there is something simple I haven't done, please
> find attached the
> output of 'ghc -v'.
>
> I burrowed around in the core file, and it looks like it is failing in
> __init_Main which appears to be doing this:
>
> if (! _module_registered) {
> _module_registered = 1;
> {
> extern F_ __init_Prelude(void) ;
> *(Sp++) = (W_)__init_Prelude ;
> }
> }
>
> do { void *_procedure = (void *)(*(--Sp)); goto
> *_procedure; } while(0);
>
> It goes into the 'if' statement and hence the top element of
> Sp becomes a
> pointer to __init_Prelude(). It then tries to call this by
> reading Sp's top
> element and then goes to that address. This would be fine
> except that what
> is really placed on Sp by the assignment is a pointer to the
> function's PLT
> entry which has (function address, DLT pointer) pairs for
> each function. The
> "goto" is just doing a simple vectored branch into the table
> rather than
> using its entries to find the true address and jumping to that.
>
> Any help would be appreciated.
> Thanks,
> Andy Bennett.
More information about the Glasgow-haskell-bugs
mailing list