Re: epoll_wait returning EFAULT on Linux 3.2.78 - Mailing list pgsql-hackers

From Greg Stark
Subject Re: epoll_wait returning EFAULT on Linux 3.2.78
Date
Msg-id CAM-w4HPzKDTCCbCe5ufO4AkSwqO5JWmL52KdMCKG3dzT73U_4A@mail.gmail.com
Whole thread Raw
In response to Re: epoll_wait returning EFAULT on Linux 3.2.78  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: epoll_wait returning EFAULT on Linux 3.2.78  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: epoll_wait returning EFAULT on Linux 3.2.78  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
So FYI, it does look like Postgres built in 32-bit mode, at least
pointers are 32 bits. But I think maxalign might still be enough due
to doubles being 64 bits.

checking whether long int is 64 bits... no
checking whether long long int is 64 bits... yes
checking snprintf length modifier for long long int... ll
checking whether snprintf supports the %z modifier... yes
checking size of void *... 4
checking size of size_t... 4
checking size of long... 4
checking whether to build with float4 passed by value... yes
checking whether to build with float8 passed by value... no
checking alignment of short... 2
checking alignment of int... 4
checking alignment of long... 4
checking alignment of long long int... 8
checking alignment of double... 8
checking for int8... no
checking for uint8... no
checking for int64... no
checking for uint64... no
checking for __int128... no

I wrote a test program based on latch.c and tested various alignments.
It does indeed get EFAULT for anything other than 8-byte alignment
(the second argument is the number of bytes to offset the events
structure):

$ echo | ./a.out 1 0
epoll_wait(epfd=5, events=0x22018, maxevents=1, timeout=-1)
success
$ echo | ./a.out 1 1
epoll_wait(epfd=5, events=0x22019, maxevents=1, timeout=-1)
epoll_wait: Bad address
$ echo | ./a.out 1 2
epoll_wait(epfd=5, events=0x2201a, maxevents=1, timeout=-1)
epoll_wait: Bad address
$ echo | ./a.out 1 4
epoll_wait(epfd=5, events=0x2201c, maxevents=1, timeout=-1)
epoll_wait: Bad address

The same program gets success for any all offsets on x86.

Attachment

pgsql-hackers by date:

Previous
From: Andreas 'ads' Scherbaum
Date:
Subject: TESTING in src/bin/pg_upgrade has incorrect documentation
Next
From: Tomas Vondra
Date:
Subject: Re: pg9.6 segfault using simple query (related to use fk for join estimates)