Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1icaQF-0003NX-O5 for pgsql-bugs@arkaria.postgresql.org; Wed, 04 Dec 2019 19:34:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1icaQD-0004Ow-Gs for pgsql-bugs@arkaria.postgresql.org; Wed, 04 Dec 2019 19:34:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1icaQD-0004O3-54 for pgsql-bugs@lists.postgresql.org; Wed, 04 Dec 2019 19:34:49 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1icaQ6-0003cd-4u for pgsql-bugs@lists.postgresql.org; Wed, 04 Dec 2019 19:34:47 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id D05025F7A6; Wed, 4 Dec 2019 14:34:40 -0500 (EST) Date: Wed, 4 Dec 2019 14:34:40 -0500 From: Stephen Frost To: Chris Bandy Cc: mark.siemers@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16041: Error shows up both in pgAdmin and in Ruby (pg gem) - Segmentation fault Message-ID: <20191204193440.GI6962@tamriel.snowman.net> References: <16041-b44f9931ad91fc3d@postgresql.org> <93f7379b-2e2f-db0c-980e-07ebd5de92ff@crunchydata.com> <20191203233132.GZ6962@tamriel.snowman.net> <94f70eee-eb72-88d7-ff8f-53cfbe130a69@crunchydata.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="VXPqQQg3PjMo6WZv" Content-Disposition: inline In-Reply-To: <94f70eee-eb72-88d7-ff8f-53cfbe130a69@crunchydata.com> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --VXPqQQg3PjMo6WZv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Chris Bandy (chris.bandy@crunchydata.com) wrote: > On 12/3/19 5:31 PM, Stephen Frost wrote: > >* Chris Bandy (chris.bandy@crunchydata.com) wrote: > >>Notice that host must be a TCP address (not Unix) and gssencmode must be > >>"prefer" (default is "prefer".) The version of the server doesn't appea= r to > >>matter; I tested 10, 11, and 12. > > > >So, gssencmode didn't exist in 10 or 11- but are you actually testing > >those different versions of *libpq*? >=20 > No, the libpq version in my tests is always 12. I was trying to say that = it > doesn't appear to be an issue with the protocol/negotiation of GSS > encryption. No, I don't think it's got anything to do with that ... or largely to do with PG, except that libpq with v12 now uses more of the GSSAPI library than it used to. > That does make me wonder, though, if/how the _server_ built by `brew inst= all > postgresql` might be impacted by the macOS GSSAPI? All my tests targeted a > linux server. I wouldn't be at all surprised if there's other bugs lurking in the old version of Heimdal that Apple hacked up and distributes with their base OS. > >>This has been reported in a variety of Ruby projects and often dismisse= d as > >>"a PostgreSQL issue." > > > >I'm really inclined to say that this isn't a PG issue... >=20 > I agree, but at the same time the perception seems to be that > using/connecting to PostgreSQL crashes one's application. I think the very > reasonable default of gssencmode=3Dprefer is partly responsible. Users do= n't > realize that by upgrading libpq they are opting in to new security code > paths (and library compatibility issues.) Perception isn't reality though and upgrading to a new major version of libpq is going to pretty regularly involves new library calls or calls being made in ways they weren't before. If that exposes a bug in that library (particularly one that's been fixed in more recent versions of the library), that's not on us to hack around or attempt to solve, imv. Perhaps someone else has a differing opinion and wants to try and figure out a way to solve this that doesn't materially make things worse for users that are running with a modern library, which would be great, but I can't get too worked up about it. > >Unfortunately, MacOS is pretty well known to be terrible about less > >commonly used libraries and maintaining them. I'd suggest building a > >current version of the Kerberos libraries, making sure you're linking > >against just those and not whatever is provided by MacOS, and see if you > >still have an issue. >=20 > Investigating this has been the deepest exposure I've had to this... yes, > "unfortunate" reality. >=20 > Homebrew provides a recent version of krb5 (1.17 at this time) so I set o= ut > to use it. A small diff to the formula proved successful. I'll submit a > patch to Homebrew linking back to this thread. Great, that sounds like it's probably the right approach to addressing this. > Is there anything that can/should be done on PostgreSQL's end now that we > know about this situation? The most I can imagine is to issue a warning w= hen > macOS's GSSAPI is detected during build/configure. I don't know how to do > the latter and won't be surprised if the answer to the former is "no." I wouldn't be against doing something here but I don't have a Mac myself and I don't plan to spend time trying to hack around their broken library. I'm also not entirely convinced that we should just throw an error if we come across this busted library- psql doesn't fork and hasn't got any problems, so it seems a bit overkill to just refuse to work with the MacOS library. > >The other possibility is that this is an current bug in Heimdal, which > >seems to be the Kerberos library being used on MacOS, in which case > >you'd need to bring up the issue with them. >=20 > I'm out of my depth on this front. My impression from the traces is that = the > incompatibility is in macOS keychain, and I'm willing to leave it at that. > While researching this topic, I found multiple cases where fork() and the > "dispatch queue" are incompatible.[1] I'm.. not terribly impressed by that blog's arguments around fork(), particularly since it seems to be claiming things that are actually not true about fork but which are true about threads. In fact, what it seems to really be getting at is that running with threads and fork'ing at the same time is awful complicated to get right, and that's pretty accurate, but that doesn't make just using fork() an issue. That blog post aside, it looks like what it's getting at is that you can't link to MacOS libraries and also fork() and expect things to be sane, and while that's unfortuante, that isn't really our issue to go figure out how to fix or address. Thanks, Stephen --VXPqQQg3PjMo6WZv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJd6ApQAAoJEO1sijiDR2RVb2oQAJ7dtX1QBQifDbqsL6uRap0c tVtOuR/PtKfzI3qBqwILQnotz163I66zRWMPmHqScstpFcU8sGiTSR+RD/0Kf2Od 1n/jPAinCpXqd01+kcNI/ZDT1kli1/qnsnUV2FF7KZkep52prEwE7bhlwSiALzyU y0AppxTPH2KVzi4qyspYnQ0V+7a9hGFCPTmo8hdb7r5SVqtPPykzn6XuDqk9/t+6 czzWF5Rs6zYk+eOccaH7rus1JxzaU/ZgH/fJNmt0CpsYBb+PGuaR75Pol9qqgIX3 C9m/szeKaY6B6YpfGOD3XUOG30UW6GjvmqQR/J8rwTMCKlOXABgo/lrNIfOzfaxO 5ElgDzeAkoA2SvwiZ/iZkOhaZYtjsI3WODxwjb6aHefASeXAOSDydDhykmyyADVU ZMhZt9C3rL6DA8LbqhPx0TOsTEXh1XjEcwnzm9l4uK3JDR+U0oH5VudPKQzXpNBT Ii+D9LW1BuhvC5jJGj86RZnzEEU/cAOJrObdTbyrKUcXGo96DkpU0xuFTA0PqovF +Q7sr61QBWMBOaHICq33XiOG927m5yOFeUyR643ZqzJb9AOcbnls1q2HXzdCmMJA 7FyWd6XayPcF22GrGrSqRPdcYUTGIn3CoMXfEGUJD6vhznjgTyeOjmT2S3bK+/9G JBss0rrKLmRFwE2ML15T =m7b7 -----END PGP SIGNATURE----- --VXPqQQg3PjMo6WZv--