`make check` doesn't pass on MacOS Catalina

From: Aleksander Alekseev <aleksander(at)timescale(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: `make check` doesn't pass on MacOS Catalina
Date: 2021-04-20 14:57:55
Message-ID: CAJ7c6TN6QONSsM3=GPdp2DtPgFpL1cY+txVwfNREWuYX9V1P=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

While trying to build PostgreSQL from source (master branch, 95c3a195) on a
MacBook I discovered that `make check` fails:

```
============== removing existing temp instance ==============
============== creating temporary instance ==============
============== initializing database system ==============
============== starting postmaster ==============
sh: line 1: 33559 Abort trap: 6 "psql" -X postgres < /dev/null 2>
/dev/null
sh: line 1: 33562 Abort trap: 6 "psql" -X postgres < /dev/null 2>
/dev/null
...
sh: line 1: 33742 Abort trap: 6 "psql" -X postgres < /dev/null 2>
/dev/null

pg_regress: postmaster did not respond within 60 seconds
Examine
/Users/eax/projects/c/postgresql/src/test/regress/log/postmaster.log for
the reason
make[1]: *** [check] Error 2
make: *** [check] Error 2
```

A little investigation revealed that pg_regres executes postgres like this:

```
PATH="/Users/eax/projects/c/postgresql/tmp_install/Users/eax/pginstall/bin:$PATH"
DYLD_LIBRARY_PATH="/Users/eax/projects/c/postgresql/tmp_install/Users/eax/pginstall/lib"
"postgres" -D
"/Users/eax/projects/c/postgresql/src/test/regress/./tmp_check/data" -F -c
"listen_addresses=" -k "/Users/eax/pgtmp/pg_regress-S34sXM" >
"/Users/eax/projects/c/postgresql/src/test/regress/log/postmaster.log"
```

... and checks that it's online by executing:

```
PATH="/Users/eax/projects/c/postgresql/tmp_install/Users/eax/pginstall/bin:$PATH"
DYLD_LIBRARY_PATH="/Users/eax/projects/c/postgresql/tmp_install/Users/eax/pginstall/lib"
psql -X postgres
```

The last command fails with:

```
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No
such file or directory. Is the server running locally and accepting
connections on that socket?
```

This is because the actual path to the socket is:

```
~/pgtmp/pg_regress-S34sXM/.s.PGSQL.5432
```

While debugging this I also discovered that psql uses
/usr/lib/libpq.5.dylib library, according to the `image list` command in
LLDB. The library is provided with the system and can't be moved or
deleted. In other words, it seems to ignore DYLD_LIBRARY_PATH. I've found
an instruction [1] that suggests that this is a behavior of MacOS integrity
protection and describes how it can be disabled. Sadly it made no
difference in my case, psql still ignores DYLD_LIBRARY_PATH.

While I'm still in the progress of investigating this I just wanted to ask
if anyone is developing on MacOS and observes anything similar and had any
luck solving the problem? I tried to search through the mailing list but
didn't find anything relevant. The complete script that reproduces the
issue is attached. I'm using the same script on Ubuntu VM, where it works
just fine.

[1]: https://github.com/rbenv/rbenv/issues/962#issuecomment-275858404

--
Best regards,
Aleksander Alekseev

Attachment Content-Type Size
pgsql-build.sh.txt text/plain 522 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2021-04-20 14:59:32 Re: Free port choosing freezes when PostgresNode::use_tcp is used on BSD systems
Previous Message Alvaro Herrera 2021-04-20 14:51:40 Re: pg_amcheck option to install extension