[unixODBC-support] Library (.so) using unixODBC built with -fPIC crashes at execute.c (line 138)

Tony Lewis lewis at biochemistry.ucl.ac.uk
Mon Nov 29 11:48:25 GMT 2004


Library (.so) using unixODBC built with -fPIC crashes at execute.c (line 
138):

I am trying to build a .so that uses unixODBC and I can get it to work 
on our 32 bit machines.  However my 64 bit machine (x86_64) demands that 
I use the option -fPIC otherwise I get the error:

relocation R_X86_64_32 can not be used when making a shared object; 
recompile with -fPIC

Whenever I compile with -fPIC (on 32 bit or 64 bit), the code crashes at 
execute.c, line 138.  That line of code is:

if ( CC_is_readonly(self->hdbc) && STMT_UPDATE(self)) {

CC_is_readonly appears to be a macro defined in connection.h as follows:

#define CC_is_readonly(x)  (x->connInfo.readonly[0] == '1')

So I added the following debug statements before the line that causes 
the crash:

printf("About to print debug statements\n");
printf("self is %p\n",self);
printf("self->hdbc is %p\n",self->hdbc);
printf("(self->hdbc)->connInfo.readonly is 
%p\n",(self->hdbc)->connInfo.readonly);
printf("(self->hdbc)->connInfo.readonly[0] is 
%c\n",(self->hdbc)->connInfo.readonly[0]);

The resulting output is:

About to print debug statements
self is 0x659650
self->hdbc is 0x4b5b
(self->hdbc)->connInfo.readonly is 0x72af
Segmentation fault

Any help very gladly appreciated...

BTW, my compile command is:
g++ -fPIC -g --shared domain.o.............segment.o -lstdc++ -L. 
-lodbcdebug -o libcathdblib.so

Regards,

Tony Lewis



More information about the unixODBC-support mailing list