From owner-freebsd-hackers@FreeBSD.ORG Fri Feb 15 13:34:56 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D64D0E65 for ; Fri, 15 Feb 2013 13:34:56 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) by mx1.freebsd.org (Postfix) with ESMTP id 7A9D9BD6 for ; Fri, 15 Feb 2013 13:34:56 +0000 (UTC) Received: from [192.168.0.6] (spaceball.home.andric.com [192.168.0.6]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 06E915C43; Fri, 15 Feb 2013 14:34:49 +0100 (CET) Message-ID: <511E397D.1000005@FreeBSD.org> Date: Fri, 15 Feb 2013 14:34:53 +0100 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20130117 Thunderbird/19.0 MIME-Version: 1.0 To: natris@centrum.cz, Konstantin Belousov Subject: Re: SIGSEGV/SIGBUS when accessing after end of mmapped file; why it differs with GCC? References: <20130213171825.76D3A9DC@centrum.cz>, <20130213191208.GR2522@kib.kiev.ua> <20130214150402.49631109@centrum.cz> In-Reply-To: <20130214150402.49631109@centrum.cz> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: "freebsd-hackers@freebsd.org" , Ryan Stone X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Feb 2013 13:34:56 -0000 On 2013-02-14 15:04, natris@centrum.cz wrote: > Od: "Konstantin Belousov" >> On Wed, Feb 13, 2013 at 12:13:58PM -0500, Ryan Stone wrote: >>> On Wed, Feb 13, 2013 at 11:18 AM, wrote: ... >>>> Machine in question runs amd64 FreeBSD 9.1-RC2, but this has also ... >> You did not specified anything about version of the FreeBSD used, nor >> the exact compiler invocations. Using the crystal ball, I see the >> r244600 for HEAD and r244904 for stable/9, if you use --gc-sections >> flags. This is more or less consistent with what you reported, since >> gcc from ports uses binutils from ports, which have newer ld with >> bugfix already applied. ... > In my case it is indeed so that while the gcc42 generated binary does not contain the note, gcc47 binary does contain it. I am indeed using --gc-sections linker option, however whether this, potentially with some bug in linker, caused the note to be missing, I am not sure, as I did not investigate into this. The solution of the original problem is thus to ensure that the note presence is consistent and that the correct signal is handled. As Kostik already pointed out, FreeBSD's ld contains a bug which erroneously strips out the note sections, if you use --gc-sections. I fixed that for head in r244600, and merged it to stable/9 in r244904. Since you said you are running FreeBSD 9.1-RC2, you will not have this particular fix, so it is the most likely cause for your problems. The reason you do not see it with gcc 4.7 is that it will use a much newer ld from the binutils port, where this issue with --gc-sections was fixed a long time ago.