[Newbie]Unexpected signal from FFI on Solaris 8

Marco Vezzoli marco.vezzoli@st.com
Fri, 09 May 2003 08:30:52 +0200


alastair@reid-consulting-uk.ltd.uk wrote:
> 
> I found myself a solaris box and was able to reproduce your bug.
> 
> To try to track down what was happening, I modified the code generated by
> ffihugs and modified your test.c and Test.hs to check that the function
> 'times' gave the same result.  Test.c and Test.hs both saw a return value of
> -1 (hence the segfault) but the modified version of test.c didn't print
> anything.
> 
> Hypothesis: there is a standard library function on solaris called 'times'
> which is shadowing your definition of times.
> 
> To test this hypothesis, I renamed the C function being called to 'times_adr',
> recompiled, reloaded and... it worked just fine.

Thank you very much! This is enough for me to continue my learning.

> 
> Does anyone know of a flag you can pass to a linker to make it report an error
> instead of silently doing the wrong thing?
> 

I tried with '--warn-common' but without success.
Then I tried to repeat the error with C only:
-I compiled a shared lib with
gcc -c test.c
ld -o libtest.so -shared test.o

-then I linked a simple test
--------main.c-------------
#include "test.h"

int main(int argc,char** argv){
        printf("%s",times('a',2));
}
--------main.c-------------
with the command
gcc -ltest -L. main.c

but the program worked correctly.
Maybe the 'times' symbol is defined in some other library that ffihugs
uses by default.

-- 
Marco Vezzoli	   tel. +39 039 603 6852
STMicroelectronics fax. +39 039 603 5055