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 1icHdv-0002TB-Q2 for pgsql-bugs@arkaria.postgresql.org; Tue, 03 Dec 2019 23:31:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1icHdu-0001Wt-3M for pgsql-bugs@arkaria.postgresql.org; Tue, 03 Dec 2019 23:31:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1icHdt-0001Sq-RI for pgsql-bugs@lists.postgresql.org; Tue, 03 Dec 2019 23:31:41 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1icHdo-0000i6-Ug for pgsql-bugs@lists.postgresql.org; Tue, 03 Dec 2019 23:31:40 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 147355F7A0; Tue, 3 Dec 2019 18:31:33 -0500 (EST) Date: Tue, 3 Dec 2019 18:31:32 -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: <20191203233132.GZ6962@tamriel.snowman.net> References: <16041-b44f9931ad91fc3d@postgresql.org> <93f7379b-2e2f-db0c-980e-07ebd5de92ff@crunchydata.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="eNAyIk4/hO2P5Mja" Content-Disposition: inline In-Reply-To: <93f7379b-2e2f-db0c-980e-07ebd5de92ff@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 --eNAyIk4/hO2P5Mja Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * 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 appear = 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*? That's really what is relevant here, I believe, if libpq is actually even relevant at all... > This has been reported in a variety of Ruby projects and often dismissed = as > "a PostgreSQL issue." I'm really inclined to say that this isn't a PG issue... > Based on that report, I crafted a minimal C program to make the same GSS > call as libpq. I compiled (with deprecation warnings) and tested with the > following: >=20 > gcc macos-gss-crash.c -o macos-gss-crash -lgssapi_krb5 > ./macos-gss-crash Particularly since that isn't linking against libpq and it's still crashing. I took the liberty to update the C code version to run on a Linux system, and sure enough, it works just fine: before gss_acquire_cred in main after gss_acquire_cred in main gss complete: true before gss_acquire_cred in child after gss_acquire_cred in child gss complete: true child exit code: 0 (also tested w/o having GSS creds and it still worked without a crash) The only difference I needed to get it to compile on my Ubuntu box was to add: #include #include and then compile as: =E2=9E=9C ~ gcc macos-gss-crash.c -o macos-gss-crash -I /usr/include/mit-k= rb5 -L /usr/lib/x86_64-linux-gnu/mit-krb5 -lgssapi_krb5=20 > It prints: >=20 > before gss_acquire_cred in main > after gss_acquire_cred in main > gss complete: true > before gss_acquire_cred in child > child signalled: 11 >=20 > I've attached the C program and crash reports for it and the above Ruby > snippet. 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. 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. There seems to be some indepedent confirmation of this being an issue with the Heimdal provided by MacOS: https://github.com/zenchild/gssapi/issues/12 The docs for gss_acquire_cred() don't seem to say much about what happens when there's a fork(): https://docs.oracle.com/cd/E19683-01/816-1331/overview-141/index.html If there's something we should be doing differently with gss_acquire_cred() to "fix" this then I'm certainly open to it but I'm really not sure what we'd do here; it seems pretty clearly to be some issue where the Kerberos/Heimdal library being used is maintaining its own state and getting confused after a fork happens. Thanks, Stephen --eNAyIk4/hO2P5Mja Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJd5vBUAAoJEO1sijiDR2RV9FYP/im5btjOrhK9hgVdEAQVqRxY kVlp1ixZcOFKOP+LSnetSXtDf+KmF7AIHK31QR54v1oE4Pg/kpyqcmh/1VazTWw1 jbxoCsFPPn5iT0fQnZDw7E1w69qCy8hEn0FRd+oDHsO8b5k3sXPJ8H4fas94isbQ jenxX/MBcUgEtRkRfz/1t7TG6ut2BjUGTg6CXnBcqDeKlBkzVdCb7WrN27BIVIC7 1EQk1fni7hJwlf1NrAhMBGtU+n40YkpMBgjmn3LZmWmO7kCvFA3sI9ifBz8+1gIJ fa+x+9xHQ342WGvuKszImgZIajNCEImcjsjyU4kl9iNDoc4qZnKtWEjSvqmgoaHw HzAmqysvWhH2GBEZX1qGe4JirZK/vWYVqEFzQB2MUn68C0yrWo7DuPsEmTpCs1ha L7pV+QYAuzrT3dvMHUSwHeehcEwkaLVZ34l4FRcKg7K4NkB/5ytPnjdtfyKe719/ 4NXlU9Z+rOYVuYENNmQrHTxkd5ALTLTF9YNy8Gb+MfmhvCKrQeJhTuRYGf2mnymn a0+712SzsGV6dVWPcQHimtDRWAxcURU4tBKaPM1pL+VNDgSRY3Xizws9gq3q4WfW S040RpOWbUOkfML6NdUBBxz4WBAlMgLr6X5ntEh+rje+N8t1BIgnHY1b+8RTjkx5 MXKkX+ceAGlclM8u4Ggj =qAPU -----END PGP SIGNATURE----- --eNAyIk4/hO2P5Mja--