SIGSEGV/SIGBUS when accessing after end of mmapped file; why it differs with GCC?

Dimitry Andric dim at FreeBSD.org
Fri Feb 15 13:34:56 UTC 2013


On 2013-02-14 15:04, natris at centrum.cz wrote:
> Od: "Konstantin Belousov" <kostikbel at gmail.com>
>> On Wed, Feb 13, 2013 at 12:13:58PM -0500, Ryan Stone wrote:
>>> On Wed, Feb 13, 2013 at 11:18 AM, <natris at centrum.cz> 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.


More information about the freebsd-hackers mailing list