postgres.git / summary / log / commit / refs

commit    a8096e30f4d08f2b90cc147b44b414191de6155f
Author:   Thomas Munro <tmunro@postgresql.org>
Date:     Thu Aug 12 22:38:22 2021 +0000
First released in: 15.0, 9.6.24, 10.19, 11.14, 12.9, 13.5, 14.0

    Make EXEC_BACKEND more convenient on macOS.
    
    It's hard to disable ASLR on current macOS releases, for testing with
    -DEXEC_BACKEND.  You could already set the environment variable
    PG_SHMEM_ADDR to something not likely to collide with mappings created
    earlier in process startup.  Let's also provide a default value that
    works on current releases and architectures, for developer convenience.
    
    As noted in the pre-existing comment, this is a horrible hack, but
    -DEXEC_BACKEND is only used by Unix-based PostgreSQL developers for
    testing some otherwise Windows-only code paths, so it seems excusable.
    
    Back-patch to all supported branches.
    
    Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
    Discussion: https://postgr.es/m/20210806032944.m4tz7j2w47mant26%40alap3.anarazel.de


src/backend/port/sysv_shmem.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c index 968506dd516..3267648c959 100644 --- a/src/backend/port/sysv_shmem.c +++ b/src/backend/port/sysv_shmem.c @@ -142,6 +142,16 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size) if (pg_shmem_addr) requestedAddress = (void *) strtoul(pg_shmem_addr, NULL, 0); + else + { +#if defined(__darwin__) && SIZEOF_VOID_P == 8 + /* + * Provide a default value that is believed to avoid problems with + * ASLR on the current macOS release. + */ + requestedAddress = (void *) 0x80000000000; +#endif + } } #endif [parent: cd7d9b6b63f1]