On Monday, October 14, 2019 at 11:28:03 PM UTC-7, Corey Csuhta wrote:
>
> Hey all:
>
> I have a reproduceable Ruby segfault when I use Puma, Sequel, and Postgres 
> together in MacOS Catalina. 
>
> I have this code in my Puma config:
>
> before_fork do
>   ::Sequel::DATABASES.each(&:disconnect)
> end
>
> That block runs correctly and the Puma workers boot, but as soon as I try 
> to send any requests to one of the workers, Sequel segfaults trying to 
> reconnect to the database in the worker process.
>
> This doesn't happen if I use Webrick, and it doesn't happen if I 
> dis/connect databases in a Rake task or with Sequel on the Ruby console. 
> Removing sequel_pg from the project also doesn't stop the segfault. It has 
> something to do with the Puma worker process, but I am unsure if Puma or 
> Sequel is the source of the issue. 
>
> I attached all the segufault details to this message, and I can run 
> other diagnostics or provide more information if needed. Help with 
> debugging this or identifying which issue tracker I should report it to 
> would be greatly appreciated. 
>
> MacOS 10.15 Catalina
> ruby 2.6.5p114 
> sequel 5.25.0
> sequel_pg 1.12.2
> puma 4.2.1
>

Thanks, the reports you provided are helpful.

This is a bug in a lower level, probably either in PostgreSQL or in Mac OS:

Thread 4 Crashed:: thread_pool.rb*  Dispatch queue: 
com.apple.security.keychain-cache-queue
0   libsystem_kernel.dylib        0x00007fff6d50b47a __pthread_kill + 10
1   libsystem_pthread.dylib        0x00007fff6d5c8707 pthread_kill + 384
2   libsystem_c.dylib              0x00007fff6d493a08 abort + 120
3   ruby                          0x0000000107cbecf9 die + 9
4   ruby                          0x0000000107cbef34 rb_bug_context + 564
5   ruby                          0x0000000107dd45a1 sigsegv + 81
6   libsystem_platform.dylib      0x00007fff6d5bdb1d _sigtramp + 29
7   ???                            000000000000000000 0 + 0
8   libdispatch.dylib              0x00007fff6d36c4de 
_dispatch_client_callout + 8
9   libdispatch.dylib              0x00007fff6d378576 
_dispatch_lane_barrier_sync_invoke_and_complete + 60
10  com.apple.security            0x00007fff42ab00b1 
Security::KeychainCore::StorageManager::tickleKeychain(Security::KeychainCore::KeychainImpl*)
 
+ 485
11  com.apple.security            0x00007fff428845c2 
Security::KeychainCore::KCCursorImpl::next(Security::KeychainCore::Item&) + 
352
12  com.apple.security            0x00007fff42a52119 
Security::KeychainCore::IdentityCursor::next(Security::SecPointer<Security::KeychainCore::Identity>&)
 
+ 217
13  com.apple.security            0x00007fff42a76c6b 
SecIdentitySearchCopyNext + 155
14  com.apple.security            0x00007fff42a81f80 
SecItemCopyMatching_osx(__CFDictionary const*, void const**) + 261
15  com.apple.security            0x00007fff42a857c8 SecItemCopyMatching + 
338
16  com.apple.Heimdal              0x00007fff57fdeb8b 0x7fff57f8d000 + 
334731
17  com.apple.Heimdal              0x00007fff57fdd6ac hx509_certs_find + 67
18  com.apple.Heimdal              0x00007fff57fb9686 _krb5_pk_find_cert + 
246
19  com.apple.GSS                  0x00007fff38d1ee3d 
_gsspku2u_acquire_cred + 386
20  com.apple.GSS                  0x00007fff38d0e2c4 gss_acquire_cred + 529
21  libpq.5.dylib                  0x000000011017d81e 
pg_GSS_have_cred_cache + 78
22  libpq.5.dylib                  0x000000011015b795 PQconnectPoll + 4885
23  libpq.5.dylib                  0x0000000110157f71 connectDBComplete + 
609
24  libpq.5.dylib                  0x000000011015814e PQconnectdb + 62
25  pg_ext.bundle                  0x0000000110118ab1 
gvl_PQconnectdb_skeleton + 17 (gvl_wrappers.c:13)
26  ruby                          0x0000000107e11cd9 call_without_gvl + 185
27  pg_ext.bundle                  0x0000000110118a8d gvl_PQconnectdb + 45 
(gvl_wrappers.c:14)
28  pg_ext.bundle                  0x000000011011dbe9 pgconn_init + 121 
(pg_connection.c:276)
29  ruby                          0x0000000107e52e96 vm_call0_body + 630
30  ruby                          0x0000000107e51451 rb_funcallv + 625
31  ruby                          0x0000000107d4d0b9 rb_class_s_new + 41


It's quite similar to a bug posted on the Ruby bugtracker earlier this 
month: https://bugs.ruby-lang.org/issues/16239.  As I said in that ticket: 

If I had to guess, this is a PostgreSQL issue with GSS authentication on 
Mac OS. Since PostgreSQL 12 was just released, it may be a regression. 
Please try contacting the PostgreSQL developers.


If you are using PostgreSQL 12, that makes it more likely this is 
regression in PostgreSQL 12, as the Ruby bug report was for Mac OS X 
Mojave, not Catalina.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/7f861609-51f2-4c40-ba89-58ab64c28c8a%40googlegroups.com.

Reply via email to