From owner-freebsd-stable@FreeBSD.ORG Mon Mar 3 22:52:08 2008 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 90B121065677 for ; Mon, 3 Mar 2008 22:52:08 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.delphij.net (delphij-pt.tunnel.tserv2.fmt.ipv6.he.net [IPv6:2001:470:1f03:2c9::2]) by mx1.freebsd.org (Postfix) with ESMTP id 45F7E8FC14 for ; Mon, 3 Mar 2008 22:52:08 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.geekcn.org (tarsier.geekcn.org [202.108.54.204]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tarsier.delphij.net (Postfix) with ESMTPS id 4B7AB28448 for ; Tue, 4 Mar 2008 06:52:07 +0800 (CST) Received: from localhost (tarsier.geekcn.org [202.108.54.204]) by tarsier.geekcn.org (Postfix) with ESMTP id 15486EBB6AF; Tue, 4 Mar 2008 06:52:07 +0800 (CST) X-Virus-Scanned: amavisd-new at geekcn.org Received: from tarsier.geekcn.org ([202.108.54.204]) by localhost (mail.geekcn.org [202.108.54.204]) (amavisd-new, port 10024) with ESMTP id Cdw8OXATdWsB; Tue, 4 Mar 2008 06:52:02 +0800 (CST) Received: from charlie.delphij.net (71.5.7.139.ptr.us.xo.net [71.5.7.139]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tarsier.geekcn.org (Postfix) with ESMTPSA id 8108FEBB6A2; Tue, 4 Mar 2008 06:52:01 +0800 (CST) DomainKey-Signature: a=rsa-sha1; s=default; d=delphij.net; c=nofws; q=dns; h=message-id:date:from:reply-to:organization:user-agent: mime-version:to:cc:subject:references:in-reply-to: x-enigmail-version:openpgp:content-type:content-transfer-encoding; b=rB9hzaxRagjiSpVqEH6EVRxETuHNOWTa+dmivUZqx/57RTvwd3bq1BLlDl+XaP0MA a3UkXIL+BoGsDuP+WM0vQ== Message-ID: <47CC810F.5030807@delphij.net> Date: Mon, 03 Mar 2008 14:51:59 -0800 From: Xin LI Organization: The FreeBSD Project User-Agent: Thunderbird 2.0.0.12 (X11/20080303) MIME-Version: 1.0 To: Alexandre Biancalana References: <8e10486b0803031424x31556698qa1bd1bbab8e8376f@mail.gmail.com> In-Reply-To: <8e10486b0803031424x31556698qa1bd1bbab8e8376f@mail.gmail.com> X-Enigmail-Version: 0.95.6 OpenPGP: id=18EDEBA0; url=http://www.delphij.net/delphij.asc Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-stable@freebsd.org Subject: Re: AMD64 only Segmentation fault (was: 7-STABLE(AMD64)+Qmail-LDAP core dump) X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: d@delphij.net List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Mar 2008 22:52:08 -0000 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 http://www.delphij.net/ FreeBSD - The Power to Serve!