[freetds] gethostbyname_r failes if statically linked
John Wythe (work)
jwythe at silksystems.com
Fri Mar 10 22:15:23 EST 2006
I am beginning to think the problem isn't freetds specific, more a Linux
libc problem.
I don't link freetds statically, rather I link unixODBC statically, which
then uses dlopen to load and access the freetds shared library. If,
however, I remove the -static from the linker command, all works fine.
I can't say for sure that the seq fault is in gethostbyname_r. I do know
that the system that was seg faulting works fine now that I link without
the -static. On both systems unixODBC,freetds, and my program are compiled
and linked locally, so I know it isn't an issue of running a binary on a
different system. The OS's in question are Redhat 6.2, and Redhat 7.x. 7.x
seg faults, 6.2 just doesn't set the h_errno field when it returns NULL.
Both systems where failing on the same step, so I am assuming they were both
having a problem with the same function, since the same change fixed both
systems.
For now, I think I can live with linking dynamically, we are moving in that
direction anyways espically for Redhat 3.
We may just limit deploying on anything but Redhat 3 and up. If some one
has encountered this, and knows how to fix it already, great, otherwise I
wouldn't spend too much time trying to track it down.
John
>> Has anyone one ever tried to statically link a program that
>> accesses both MySQL and unixODBC. The reason I ask is that
>> the gethostbyname_r function acts strange of seg faults
>> when my program is linked statically, dynamically it works
>
> Mmm.... how did you link freetds statically?
> gethostname require some additional libraries (like nssswitch) to work,
> did you have these libraries and configurations (are you running a
> chrooted environment?)
>
>> find, as do the isql and iusql programs. The call to
>> gethostbyname_r in question is deep inside freetds in the
>> threadsafe.c source. If my program is statically linked it
>> always returns NULL, and h_errno is never changed. All
>
> gethostbyname_r is a system function (libc) if it return NULL FreeTDS
> fail connection. However it should not seg fault... where does the
> program seg fault?
>
>> programs and code are compiled on the system in question
>> freetds, unixODBC, and my program. My thinking is that
>> somehow the dlopened tds library is somehow accessing a copy
>> of gethostbyname_r that is statically linked into my program,
>> instead of one that is dynamically available. Maybe somehow
>> there are too different libraries with the same function, and
>> my program gets a different one (maybe because of MySQL) when
>> linked statically.
>>
>
> dlopened?? Are you mixing static and dynamic linking together??
>
> freddy77
>
>
> ------------------------------
>
> Message: 4
> Date: Fri, 10 Mar 2006 10:08:43 +0100
> From: "Robert Klemme" <shortcutter at googlemail.com>
> Subject: Re: [freetds] freetds on cygwin
> To: "FreeTDS Development Group" <freetds at lists.ibiblio.org>
> Message-ID: <9e3fd2c80603100108o449d655cm at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> 2006/3/10, sira <siiraa at umich.edu>:
>> Hi,
>>
>> I've successfully installed freetds 0.63 on Cygwin (the tsql works so i
>> guess i have freetds configured right).
>>
>> However i'm trying to use DBD::Sybase module with freetds and I have
>> the following error when i run my test perl script to test the
>> connection:
>>
>> $ ./testsybase.pl
>> src/tds/login.c: tds_connect: 192.168.1.65:4000: Connection refused
>> DBI connect('server=DB3','sira',...) failed: OpenClient message: LAYER
>> = (0) ORI
>> GIN = (0) SEVERITY = (78) NUMBER = (41)
>> Server DB3, database
>> Message String: Server is unavailable or does not exist.
>>
>>
>> I've double checked that my server address is correct.
>>
>> I also suspect that this might be a firewall issue. could this be the
>> case?
>
> Yes. As well as any other network related issue (no route etc.). Did
> you try to telnet the port? Did it work?
>
> Kind regards
>
> robert
>
> --
> Have a look: http://www.flickr.com/photos/fussel-foto/
>
>
> ------------------------------
>
> Message: 5
> Date: Fri, 10 Mar 2006 08:56:21 -0500
> From: "James K. Lowden" <jklowden at freetds.org>
> Subject: Re: [freetds] freetds on cygwin
> To: FreeTDS Development Group <freetds at lists.ibiblio.org>
> Message-ID: <20060310085621.79b8c351.jklowden at freetds.org>
> Content-Type: text/plain; charset=US-ASCII
>
> sira wrote:
>> $ ./testsybase.pl
>> src/tds/login.c: tds_connect: 192.168.1.65:4000: Connection refused
>> DBI connect('server=DB3','sira',...) failed: OpenClient message: LAYER
>> = (0) ORI
>> GIN = (0) SEVERITY = (78) NUMBER = (41)
>> Server DB3, database
>> Message String: Server is unavailable or does not exist.
>>
>>
>> I've double checked that my server address is correct.
>
> Is that a Sybase server you're connecting to? 4000 is the default Sybase
> port.
>
> If you know the port is right, and you're clearly getting a 'Connection
> refused' message from tds_connect, then, yes, I'd look at the network.
>
> HTH.
>
> --jkl
>
>
> ------------------------------
>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>
>
> End of FreeTDS Digest, Vol 38, Issue 9
> **************************************
>
>
More information about the FreeTDS
mailing list