Issue 8394 - LMDB fails GCC5 without -fno-strict-aliasing
Summary: LMDB fails GCC5 without -fno-strict-aliasing
Status: UNCONFIRMED
Alias: None
Product: LMDB
Classification: Unclassified
Component: liblmdb (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-01 23:05 UTC by bdallen@nps.edu
Modified: 2020-03-12 15:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bdallen@nps.edu 2016-04-01 23:05:22 UTC
Full_Name: Bruce Allen
Version: 2.4.44
OS: Fedora 23
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (205.155.65.226)


LMDB v0.9.18 crashes with segmentation fault in mdb.c line 6590 when compiled
using these compilers:
* gcc (GCC) 5.3.1 20151207 (Red Hat 5.3.1-2)
* x86_64-w64-mingw32-gcc (GCC) 5.2.0 20150716 (Fedora MinGW 5.2.0-1.fc23)

The crash happens afterrititing the 12'th item (with the same key but different
value using flags MDB_NODUPDATA and MDB_DUPSORT).

The problem goes away when compiling mdb.c with the -fno-strict-aliasing flag.
Comment 1 Howard Chu 2016-04-03 16:44:34 UTC
bdallen@nps.edu wrote:
> Full_Name: Bruce Allen
> Version: 2.4.44
> OS: Fedora 23
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (205.155.65.226)
>
>
> LMDB v0.9.18 crashes with segmentation fault in mdb.c line 6590 when compiled
> using these compilers:
> * gcc (GCC) 5.3.1 20151207 (Red Hat 5.3.1-2)
> * x86_64-w64-mingw32-gcc (GCC) 5.2.0 20150716 (Fedora MinGW 5.2.0-1.fc23)
>
> The crash happens afterrititing the 12'th item (with the same key but different
> value using flags MDB_NODUPDATA and MDB_DUPSORT).

Your message appears garbled here. Please send a test case with steps to 
reproduce.
>
> The problem goes away when compiling mdb.c with the -fno-strict-aliasing flag.
>
>


-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

Comment 2 bdallen@nps.edu 2016-04-04 16:30:35 UTC
My initial report was garbled.

What I mean is that a protection violation occurs in mdb.c when I add a
13'th item to a multiset and I compile with one of the mentioned
compilers and with -fPIC -O3.  The code works fine when compiled with
older GCC compilers or with -O0 or with -fno-strict-aliasing.

Given what I read at https://gcc.gnu.org/bugs/ under section "Casting
does not work as expected when optimization is turned on", I suspect the
problem is simply that a pointer variable is not following the ISO C
aliasing rules and breaks with the new, more aggressive compiler
optimization.

Here is the part that fails:

                    for (i=0; i<NUMKEYS(fp); i++)
                        mp->mp_ptrs[i] = fp->mp_ptrs[i] + offset;

If this turns out to not be straightforward, I can try building a small
test program to reproduce the problem.



On 04/03/2016 09:44 AM, Howard Chu wrote:
> bdallen@nps.edu wrote:
>> Full_Name: Bruce Allen
>> Version: 2.4.44
>> OS: Fedora 23
>> URL: ftp://ftp.openldap.org/incoming/
>> Submission from: (NULL) (205.155.65.226)
>>
>>
>> LMDB v0.9.18 crashes with segmentation fault in mdb.c line 6590 when
>> compiled
>> using these compilers:
>> * gcc (GCC) 5.3.1 20151207 (Red Hat 5.3.1-2)
>> * x86_64-w64-mingw32-gcc (GCC) 5.2.0 20150716 (Fedora MinGW
>> 5.2.0-1.fc23)
>>
>> The crash happens afterrititing the 12'th item (with the same key but
>> different
>> value using flags MDB_NODUPDATA and MDB_DUPSORT).
>
> Your message appears garbled here. Please send a test case with steps
> to reproduce.
>>
>> The problem goes away when compiling mdb.c with the
>> -fno-strict-aliasing flag.
>>
>>
>
>