Alexandre Biancalana wrote:
Hi list,
I found a situation that I can't explain, I have qmail-ldap running
at some FreeBSD 6.2 without any problem. Friday after Installed a new
server this time with 7-STABLE. I stated to get core dumped from
qmail-ldap when they try access the OpenLDAP database.
I compiled/run this simple C program in 7-STABLE i386 and AMD64 and
the program dumps the core only in AMD64.
I have tried to reproduce the problem and have the following
observations. To make a long story short, you *must* either use the new
ldap_initialize API instead of the old one, or to define LDAP_DEPRECATED
at the risk of having the program to break in the future, and *NOT*
ignoring any warnings issued by the compiler.
So here is the reason why we have a coredump. ldap_init is defined only
when LDAP_DEPRECATED is defined, when ldap.h is included, and by
default, C will assume that the return type is "int".
On i386, this is not a problem because sizeof(int) equals to sizeof(void
*), and the implicit cast would work; On amd64, we have sizeof(int) ==
4 and sizeof(void *) == 8, by casting the result to int (because the
header did not gave the type of ldap_init), and back (because of the
assignment ld =), we lose 4 bytes (the high 32 bits) of the pointer, and
therefore, when referring it we got a SEGV.
This is one of the most common culprit when your 32-bit application
"magically" broken on amd64 :-)
Cheers,
--
Xin LI <[EMAIL PROTECTED]> http://www.delphij.net/
FreeBSD - The Power to Serve!
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[EMAIL PROTECTED]"