Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault with ruby 2.7.8 and pg 1.5.3 #536

Open
jean-francois-labbe opened this issue May 23, 2023 · 10 comments
Open

Segmentation fault with ruby 2.7.8 and pg 1.5.3 #536

jean-francois-labbe opened this issue May 23, 2023 · 10 comments

Comments

@jean-francois-labbe
Copy link

jean-francois-labbe commented May 23, 2023

Hi, We're facing a Segmentation fault with ruby 2.7.8 and pg 1.5.3 in a rails application (v6.1.7). This is sometimes happening in CI. It is sometimes reproducible locally but I haven't found the right conditions to always reproduce the issue.

Stack trace

/tmp/bundler-cache/2.7.8/ruby/2.7.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/postgresql_adapter.rb:687: [BUG] Segmentation fault at 0x0000000000000219
ruby 2.7.8p225 (2023-03-30 revision 1f4d455848) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0101 p:---- s:0688 e:000687 CFUNC  :exec
c:0100 p:0025 s:0683 e:000682 METHOD /tmp/bundler-cache/2.7.8/ruby/2.7.0/gems/pg-1.5.3/lib/pg/basic_type_registry.rb:116 [FINISH]
c:0099 p:---- s:0675 e:000674 CFUNC  :new
c:0098 p:0074 s:0669 e:000668 METHOD /tmp/bundler-cache/2.7.8/ruby/2.7.0/gems/pg-1.5.3/lib/pg/basic_type_registry.rb:166
c:0097 p:0007 s:0662 e:000661 METHOD /tmp/bundler-cache/2.7.8/ruby/2.7.0/gems/pg-1.5.3/lib/pg/basic_type_map_for_results.rb:94 [FINISH]
c:0096 p:---- s:0654 e:000653 CFUNC  :new
c:0095 p:0054 s:0649 e:000648 METHOD /project/lib/execute_sql_file.rb:10
c:0094 p:0018 s:0642 e:000641 METHOD /project/app/models/thing.rb:174

Actual failing code

class ExecuteSQLFile
  include ActiveRecord::ConnectionAdapters::Quoting

  def initialize(filename)
    @filename = filename
  end

  def result(params = {})
    pg = ActiveRecord::Base.connection
    @type_map ||= PG::BasicTypeMapForResults.new(pg.raw_connection)  <---- failing here
    result = pg.execute(query % quoted_parameters(params))
    result.type_map = @type_map
    result
  end
  ...
end

Is there anything I can try to fix it ?
Maybe the answer is to just upgrade ruby version.

[EDIT]
Also seeing the issue with ruby 3.0.6
The stack trace has more details with this ruby version.

/tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/pg-1.5.3/lib/pg/basic_type_registry.rb:116: [BUG] Segmentation fault at 0x0000000000000538
ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0101 p:---- s:0688 e:000687 CFUNC  :exec
c:0100 p:0025 s:0683 e:000682 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/pg-1.5.3/lib/pg/basic_type_registry.rb:116 [FINISH]
c:0099 p:---- s:0675 e:000674 CFUNC  :new
c:0098 p:0074 s:0669 e:000668 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/pg-1.5.3/lib/pg/basic_type_registry.rb:166
c:0097 p:0007 s:0662 e:000661 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/pg-1.5.3/lib/pg/basic_type_map_for_results.rb:94 [FINISH]
c:0096 p:---- s:0654 e:000653 CFUNC  :new
c:0095 p:0047 s:0649 e:000648 METHOD /project/lib/execute_sql_file.rb:10
c:0094 p:0018 s:0642 e:000641 METHOD /project/app/models/thing.rb:174
c:0093 p:0003 s:0638 e:000637 METHOD /project/app/models/thing.rb:146
c:0092 p:0015 s:0634 e:000633 METHOD /project/app/controllers/thing_controller.rb:15
c:0091 p:0010 s:0630 e:000629 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_controller/metal/basic_implicit_render.rb:6
c:0090 p:0009 s:0624 e:000623 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/abstract_controller/base.rb:228
c:0089 p:0024 s:0618 e:000617 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_controller/metal/rendering.rb:30
c:0088 p:0009 s:0613 e:000612 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/abstract_controller/callbacks.rb:42
c:0087 p:0048 s:0610 e:000608 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:117
c:0086 p:0013 s:0600 e:000599 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actiontext-6.1.7/lib/action_text/rendering.rb:20
c:0085 p:0021 s:0594 e:000593 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actiontext-6.1.7/lib/action_text/engine.rb:59 [FINISH]
c:0084 p:---- s:0589 e:000588 CFUNC  :instance_exec
c:0083 p:0127 s:0583 e:000582 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:126
c:0082 p:0022 s:0574 e:000573 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/audited-5.0.2/lib/audited/sweeper.rb:16
c:0081 p:0127 s:0569 e:000568 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:126
c:0080 p:0022 s:0560 e:000559 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/audited-5.0.2/lib/audited/sweeper.rb:16
c:0079 p:0127 s:0555 e:000554 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:126
c:0078 p:0124 s:0546 E:000e48 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:137
c:0077 p:0006 s:0537 E:0024d8 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/abstract_controller/callbacks.rb:41
c:0076 p:0008 s:0532 e:000531 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_controller/metal/rescue.rb:22
c:0075 p:0009 s:0526 e:000525 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_controller/metal/instrumentation.rb:34
c:0074 p:0010 s:0521 e:000520 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/activesupport-6.1.7/lib/active_support/notifications.rb:203
c:0073 p:0022 s:0518 e:000517 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/activesupport-6.1.7/lib/active_support/notifications/instrumenter.rb:24
c:0072 p:0023 s:0510 e:000509 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/activesupport-6.1.7/lib/active_support/notifications.rb:203
c:0071 p:0098 s:0504 e:000503 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_controller/metal/instrumentation.rb:33
c:0070 p:0017 s:0498 e:000497 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_controller/metal/params_wrapper.rb:249
c:0069 p:0026 s:0493 e:000492 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/railties/controller_runtime.rb:27
c:0068 p:0080 s:0487 e:000486 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/abstract_controller/base.rb:165
c:0067 p:0062 s:0480 e:000479 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionview-6.1.7/lib/action_view/rendering.rb:39
c:0066 p:0017 s:0474 e:000473 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_controller/metal.rb:190
c:0065 p:0034 s:0467 e:000466 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_controller/metal.rb:254
c:0064 p:0010 s:0460 e:000459 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/routing/route_set.rb:50
c:0063 p:0036 s:0452 e:000451 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/routing/route_set.rb:33
c:0062 p:0110 s:0444 e:000443 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/journey/router.rb:50 [FINISH]
c:0061 p:---- s:0431 e:000430 CFUNC  :each
c:0060 p:0008 s:0427 e:000426 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/journey/router.rb:32
c:0059 p:0042 s:0422 e:000421 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/routing/route_set.rb:842
c:0058 p:0073 s:0416 e:000415 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/serviceworker-rails-0.6.0/lib/serviceworker/middleware.rb:35
c:0057 p:0112 s:0410 e:000409 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/flipper-0.26.0/lib/flipper/middleware/memoizer.rb:72
c:0056 p:0031 s:0403 e:000402 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/flipper-0.26.0/lib/flipper/middleware/memoizer.rb:37
c:0055 p:0017 s:0397 e:000396 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/warden-1.2.9/lib/warden/manager.rb:36 [FINISH]
c:0054 p:---- s:0394 e:000393 CFUNC  :catch
c:0053 p:0057 s:0389 e:000388 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/warden-1.2.9/lib/warden/manager.rb:34
c:0052 p:0035 s:0383 e:000382 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/rack-2.2.6.4/lib/rack/tempfile_reaper.rb:15
c:0051 p:0007 s:0374 e:000373 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/rack-2.2.6.4/lib/rack/etag.rb:27
c:0050 p:0050 s:0363 e:000362 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/rack-2.2.6.4/lib/rack/conditional_get.rb:27
c:0049 p:0007 s:0354 e:000353 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/rack-2.2.6.4/lib/rack/head.rb:12
c:0048 p:0026 s:0346 e:000345 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/http/permissions_policy.rb:22
c:0047 p:0026 s:0336 e:000335 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/http/content_security_policy.rb:19
c:0046 p:0026 s:0323 e:000322 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/rack-2.2.6.4/lib/rack/session/abstract/id.rb:266
c:0045 p:0005 s:0312 e:000311 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/rack-2.2.6.4/lib/rack/session/abstract/id.rb:260
c:0044 p:0026 s:0307 e:000306 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/middleware/cookies.rb:689
c:0043 p:0008 s:0297 e:000296 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/middleware/callbacks.rb:27
c:0042 p:0024 s:0294 e:000293 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:98
c:0041 p:0009 s:0285 e:000284 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/middleware/callbacks.rb:26
c:0040 p:0016 s:0278 e:000277 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/middleware/executor.rb:14
c:0039 p:0037 s:0270 e:000269 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/middleware/actionable_exceptions.rb:18
c:0038 p:0028 s:0264 e:000263 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/sentry-rails-5.7.0/lib/sentry/rails/rescued_exception_interceptor.rb:12
c:0037 p:0026 s:0258 e:000257 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/middleware/debug_exceptions.rb:29
c:0036 p:0066 s:0247 e:000246 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/sentry-ruby-5.7.0/lib/sentry/rack/capture_exceptions.rb:28
c:0035 p:0020 s:0240 e:000239 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/sentry-ruby-5.7.0/lib/sentry/hub.rb:220
c:0034 p:0017 s:0235 e:000234 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/sentry-ruby-5.7.0/lib/sentry-ruby.rb:375
c:0033 p:0013 s:0230 e:000229 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/sentry-ruby-5.7.0/lib/sentry/rack/capture_exceptions.rb:19
c:0032 p:0009 s:0226 e:000225 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/sentry-ruby-5.7.0/lib/sentry/hub.rb:59
c:0031 p:0017 s:0221 e:000220 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/sentry-ruby-5.7.0/lib/sentry-ruby.rb:355
c:0030 p:0045 s:0216 e:000215 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/sentry-ruby-5.7.0/lib/sentry/rack/capture_exceptions.rb:18
c:0029 p:0026 s:0211 e:000210 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/middleware/show_exceptions.rb:33
c:0028 p:0041 s:0204 e:000203 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/railties-6.1.7/lib/rails/rack/logger.rb:37
c:0027 p:0008 s:0194 e:000193 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/railties-6.1.7/lib/rails/rack/logger.rb:26
c:0026 p:0004 s:0191 e:000190 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/activesupport-6.1.7/lib/active_support/tagged_logging.rb:99
c:0025 p:0012 s:0188 e:000187 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/activesupport-6.1.7/lib/active_support/tagged_logging.rb:37
c:0024 p:0015 s:0182 e:000181 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/activesupport-6.1.7/lib/active_support/tagged_logging.rb:99
c:0023 p:0040 s:0176 e:000175 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/railties-6.1.7/lib/rails/rack/logger.rb:26
c:0022 p:0052 s:0170 e:000169 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/middleware/remote_ip.rb:81
c:0021 p:0043 s:0164 e:000163 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/middleware/request_id.rb:26
c:0020 p:0100 s:0158 e:000157 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/rack-2.2.6.4/lib/rack/method_override.rb:24
c:0019 p:0020 s:0152 e:000151 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/rack-2.2.6.4/lib/rack/runtime.rb:22
c:0018 p:0033 s:0142 e:000141 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/activesupport-6.1.7/lib/active_support/cache/strategy/local_cache_middleware.rb:29
c:0017 p:0016 s:0135 e:000134 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/middleware/executor.rb:14
c:0016 p:0018 s:0127 e:000126 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/middleware/static.rb:24
c:0015 p:0007 s:0122 e:000121 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/rack-2.2.6.4/lib/rack/sendfile.rb:110
c:0014 p:0015 s:0110 e:000109 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/actionpack-6.1.7/lib/action_dispatch/middleware/host_authorization.rb:142
c:0013 p:0016 s:0104 e:000103 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/railties-6.1.7/lib/rails/engine.rb:539
c:0012 p:0144 s:0098 e:000097 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/rack-2.2.6.4/lib/rack/urlmap.rb:74 [FINISH]
c:0011 p:---- s:0089 e:000088 CFUNC  :each
c:0010 p:0134 s:0085 e:000084 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/rack-2.2.6.4/lib/rack/urlmap.rb:58
c:0009 p:0051 s:0073 e:000072 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/capybara-3.38.0/lib/capybara/server/middleware.rb:60
c:0008 p:0028 s:0066 e:000065 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/puma-5.6.5/lib/puma/configuration.rb:252
c:0007 p:0008 s:0061 e:000060 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/puma-5.6.5/lib/puma/request.rb:77
c:0006 p:0023 s:0058 e:000057 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/puma-5.6.5/lib/puma/thread_pool.rb:340
c:0005 p:0300 s:0053 e:000052 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/puma-5.6.5/lib/puma/request.rb:76
c:0004 p:0139 s:0032 e:000031 METHOD /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/puma-5.6.5/lib/puma/server.rb:443 [FINISH]
c:0003 p:---- s:0020 e:000019 IFUNC 
c:0002 p:0104 s:0017 e:000014 BLOCK  /tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/puma-5.6.5/lib/puma/thread_pool.rb:147 [FINISH]
c:0001 p:---- s:0003 e:000002 (none) [FINISH]
@larskanis
Copy link
Collaborator

Can you get a C level backtrace? It usually looks like here.

@jean-francois-labbe
Copy link
Author

jean-francois-labbe commented May 23, 2023

Can you get a C level backtrace? It usually looks like here.

Here it is for ruby 3.0.6, can't have the 2.7.8 one:

-- C level backtrace information -------------------------------------------
/usr/local/lib/libruby.so.3.0(rb_print_backtrace+0x11) [0x7fc31c0449ec] vm_dump.c:758
/usr/local/lib/libruby.so.3.0(rb_vm_bugreport) vm_dump.c:998
/usr/local/lib/libruby.so.3.0(rb_bug_for_fatal_signal+0xf0) [0x7fc31be4ef60] error.c:787
/usr/local/lib/libruby.so.3.0(sigsegv+0x49) [0x7fc31bf9c239] signal.c:963
/lib/x86_64-linux-gnu/libpthread.so.0(__restore_rt+0x0) [0x7fc31bd4c140]
/lib/x86_64-linux-gnu/libc.so.6(0x7fc31bac1b2a) [0x7fc31bac1b2a]
/usr/lib/x86_64-linux-gnu/libpq.so.5(0x7fc318090e62) [0x7fc318090e62]
/usr/lib/x86_64-linux-gnu/libpq.so.5(0x7fc31809b5b0) [0x7fc31809b5b0]
/usr/lib/x86_64-linux-gnu/libpq.so.5(PQisBusy+0x3d) [0x7fc31809140d]
/tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/pg-1.5.3/lib/pg_ext.so(gvl_PQisBusy_skeleton+0xc) [0x7fc3180d7f4c] gvl_wrappers.c:14
/usr/local/lib/libruby.so.3.0(rb_nogvl+0xce) [0x7fc31bfe806e] thread.c:1695
/tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/pg-1.5.3/lib/pg_ext.so(gvl_PQisBusy+0x28) [0x7fc3180d8738] gvl_wrappers.c:16
/tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/pg-1.5.3/lib/pg_ext.so(get_result_readable+0x8) [0x7fc3180e1078] pg_connection.c:3005
/tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/pg-1.5.3/lib/pg_ext.so(wait_socket_readable) pg_connection.c:2395
/tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/pg-1.5.3/lib/pg_ext.so(pgconn_async_get_last_result) pg_connection.c:3111
/tmp/bundler-cache/3.0.6/ruby/3.0.0/gems/pg-1.5.3/lib/pg_ext.so(pgconn_async_exec+0x2c) [0x7fc3180e220c] pg_connection.c:3260
/usr/local/lib/libruby.so.3.0(vm_cfp_consistent_p+0x0) [0x7fc31c01b7dc] vm_insnhelper.c:2928
/usr/local/lib/libruby.so.3.0(vm_call_cfunc_with_frame) vm_insnhelper.c:2930
/usr/local/lib/libruby.so.3.0(vm_sendish+0x37f) [0x7fc31c02677f] vm_insnhelper.c:4529
/usr/local/lib/libruby.so.3.0(vm_exec_core+0x94) [0x7fc31c029664] insns.def:789
/usr/local/lib/libruby.so.3.0(rb_vm_exec+0x182) [0x7fc31c02ebd2] vm.c:2162
/usr/local/lib/libruby.so.3.0(rb_call0+0x1e5) [0x7fc31c0345d5] vm_eval.c:72
/usr/local/lib/libruby.so.3.0(rb_call+0x32) [0x7fc31c035022] vm_eval.c:832
/usr/local/lib/libruby.so.3.0(rb_funcallv_kw) vm_eval.c:1032
/usr/local/lib/libruby.so.3.0(rb_class_new_instance_pass_kw+0x4e) [0x7fc31bf03b0e] object.c:2110
/usr/local/lib/libruby.so.3.0(vm_cfp_consistent_p+0x0) [0x7fc31c01b7dc] vm_insnhelper.c:2928
/usr/local/lib/libruby.so.3.0(vm_call_cfunc_with_frame) vm_insnhelper.c:2930
/usr/local/lib/libruby.so.3.0(vm_sendish+0x37f) [0x7fc31c02677f] vm_insnhelper.c:4529
/usr/local/lib/libruby.so.3.0(vm_exec_core+0x94) [0x7fc31c029664] insns.def:789
/usr/local/lib/libruby.so.3.0(rb_vm_exec+0x182) [0x7fc31c02ebd2] vm.c:2162
/usr/local/lib/libruby.so.3.0(rb_call0+0x1e5) [0x7fc31c0345d5] vm_eval.c:72
/usr/local/lib/libruby.so.3.0(rb_call+0x32) [0x7fc31c035022] vm_eval.c:832
/usr/local/lib/libruby.so.3.0(rb_funcallv_kw) vm_eval.c:1032
/usr/local/lib/libruby.so.3.0(rb_class_new_instance_pass_kw+0x4e) [0x7fc31bf03b0e] object.c:2110
/usr/local/lib/libruby.so.3.0(vm_cfp_consistent_p+0x0) [0x7fc31c01b7dc] vm_insnhelper.c:2928
/usr/local/lib/libruby.so.3.0(vm_call_cfunc_with_frame) vm_insnhelper.c:2930
/usr/local/lib/libruby.so.3.0(vm_sendish+0x37f) [0x7fc31c02677f] vm_insnhelper.c:4529
/usr/local/lib/libruby.so.3.0(vm_exec_core+0x94) [0x7fc31c029664] insns.def:789
/usr/local/lib/libruby.so.3.0(rb_vm_exec+0x182) [0x7fc31c02ebd2] vm.c:2162
/usr/local/lib/libruby.so.3.0(yield_under+0x3db) [0x7fc31c03de2b] vm.c:1263
/usr/local/lib/libruby.so.3.0(vm_cfp_consistent_p+0x0) [0x7fc31c01b7dc] vm_insnhelper.c:2928
/usr/local/lib/libruby.so.3.0(vm_call_cfunc_with_frame) vm_insnhelper.c:2930
/usr/local/lib/libruby.so.3.0(vm_call_symbol+0x174) [0x7fc31c03b104] vm_insnhelper.c:3142
/usr/local/lib/libruby.so.3.0(vm_sendish+0x37f) [0x7fc31c02677f] vm_insnhelper.c:4529
/usr/local/lib/libruby.so.3.0(vm_exec_core+0x103) [0x7fc31c0296d3] insns.def:770
/usr/local/lib/libruby.so.3.0(rb_vm_exec+0x182) [0x7fc31c02ebd2] vm.c:2162
/usr/local/lib/libruby.so.3.0(rb_yield+0x25b) [0x7fc31c03c0eb] vm.c:1263
/usr/local/lib/libruby.so.3.0(RB_FL_TEST_RAW+0x0) [0x7fc31bdbb82c] array.c:2523
/usr/local/lib/libruby.so.3.0(RB_FL_ANY_RAW) ./include/ruby/internal/fl_type.h:258
/usr/local/lib/libruby.so.3.0(rb_array_len) ./include/ruby/internal/core/rarray.h:135
/usr/local/lib/libruby.so.3.0(rb_ary_each) array.c:2522
/usr/local/lib/libruby.so.3.0(vm_cfp_consistent_p+0x0) [0x7fc31c01b7dc] vm_insnhelper.c:2928
/usr/local/lib/libruby.so.3.0(vm_call_cfunc_with_frame) vm_insnhelper.c:2930
/usr/local/lib/libruby.so.3.0(vm_sendish+0x37f) [0x7fc31c02677f] vm_insnhelper.c:4529
/usr/local/lib/libruby.so.3.0(vm_exec_core+0x103) [0x7fc31c0296d3] insns.def:770
/usr/local/lib/libruby.so.3.0(rb_vm_exec+0x182) [0x7fc31c02ebd2] vm.c:2162
/usr/local/lib/libruby.so.3.0(catch_i+0x2bc) [0x7fc31c03117c] vm.c:1263
/usr/local/lib/libruby.so.3.0(vm_catch_protect+0xe2) [0x7fc31c021b52] vm_eval.c:2405
/usr/local/lib/libruby.so.3.0(rb_catch_obj+0x4d) [0x7fc31c021d1d] vm_eval.c:2431
/usr/local/lib/libruby.so.3.0(vm_cfp_consistent_p+0x0) [0x7fc31c01b7dc] vm_insnhelper.c:2928
/usr/local/lib/libruby.so.3.0(vm_call_cfunc_with_frame) vm_insnhelper.c:2930
/usr/local/lib/libruby.so.3.0(vm_sendish+0x37f) [0x7fc31c02677f] vm_insnhelper.c:4529
/usr/local/lib/libruby.so.3.0(vm_exec_core+0x103) [0x7fc31c0296d3] insns.def:770
/usr/local/lib/libruby.so.3.0(rb_vm_exec+0x182) [0x7fc31c02ebd2] vm.c:2162
/usr/local/lib/libruby.so.3.0(rb_yield+0x25b) [0x7fc31c03c0eb] vm.c:1263
/usr/local/lib/libruby.so.3.0(RB_FL_TEST_RAW+0x0) [0x7fc31bdbb82c] array.c:2523
/usr/local/lib/libruby.so.3.0(RB_FL_ANY_RAW) ./include/ruby/internal/fl_type.h:258
/usr/local/lib/libruby.so.3.0(rb_array_len) ./include/ruby/internal/core/rarray.h:135
/usr/local/lib/libruby.so.3.0(rb_ary_each) array.c:2522
/usr/local/lib/libruby.so.3.0(vm_cfp_consistent_p+0x0) [0x7fc31c01b7dc] vm_insnhelper.c:2928
/usr/local/lib/libruby.so.3.0(vm_call_cfunc_with_frame) vm_insnhelper.c:2930
/usr/local/lib/libruby.so.3.0(vm_sendish+0x37f) [0x7fc31c02677f] vm_insnhelper.c:4529
/usr/local/lib/libruby.so.3.0(vm_exec_core+0x103) [0x7fc31c0296d3] insns.def:770
/usr/local/lib/libruby.so.3.0(rb_vm_exec+0x182) [0x7fc31c02ebd2] vm.c:2162
/usr/local/lib/libruby.so.3.0(rb_vm_call0+0xd3) [0x7fc31c032513] vm_eval.c:57
/usr/local/lib/libruby.so.3.0(rb_method_call_with_block_kw+0x83) [0x7fc31bf3c003] proc.c:2416
/usr/local/lib/libruby.so.3.0(rb_vm_pop_frame+0x0) [0x7fc31c024e9d] vm_insnhelper.c:3734
/usr/local/lib/libruby.so.3.0(vm_yield_with_cfunc) vm_insnhelper.c:3735
/usr/local/lib/libruby.so.3.0(vm_invoke_ifunc_block) vm_insnhelper.c:3884
/usr/local/lib/libruby.so.3.0(vm_sendish+0x37f) [0x7fc31c02677f] vm_insnhelper.c:4529
/usr/local/lib/libruby.so.3.0(vm_exec_core+0x94) [0x7fc31c029664] insns.def:789
/usr/local/lib/libruby.so.3.0(rb_vm_exec+0x182) [0x7fc31c02ebd2] vm.c:2162
/usr/local/lib/libruby.so.3.0(rb_vm_invoke_proc+0x57) [0x7fc31c031b47] vm.c:1485
/usr/local/lib/libruby.so.3.0(thread_do_start_proc+0x17a) [0x7fc31bfe5dda] thread.c:736
/usr/local/lib/libruby.so.3.0(thread_do_start+0x14) [0x7fc31bfe64f4] thread.c:755
/usr/local/lib/libruby.so.3.0(thread_start_func_2) thread.c:834
/usr/local/lib/libruby.so.3.0(register_cached_thread_and_wait+0x0) [0x7fc31bfe6efa] thread_pthread.c:994
/usr/local/lib/libruby.so.3.0(thread_start_func_1) thread_pthread.c:1001
/lib/x86_64-linux-gnu/libpthread.so.0(0x7ea7) [0x7fc31bd40ea7]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f) [0x7fc31ba4ea2f]

@joshleblanc
Copy link

I can't provide much information for this, but we're seeing a crash with ruby 2.7.8 on windows with the PG gem, but the only thing windows is reporting about the error is error code -1073740940, which I think is a heap stack corruption.

@jean-francois-labbe
Copy link
Author

@larskanis Found the ruby 2.7.8 C backtrace.

-- C level backtrace information -------------------------------------------
/usr/local/lib/libruby.so.2.7(rb_vm_bugreport+0x50a) [0x7f70509feefa] vm_dump.c:755
[0x7f705086fdc7]
/usr/local/lib/libruby.so.2.7(sigsegv+0x49) [0x7f705097bbc9] signal.c:946
/lib/x86_64-linux-gnu/libc.so.6(0x7f7050623d60) [0x7f7050623d60]
/lib/x86_64-linux-gnu/libc.so.6(0x7f705075d911) [0x7f705075d911]
/usr/lib/x86_64-linux-gnu/libpq.so.5(0x7f704caeacf7) [0x7f704caeacf7]
/usr/lib/x86_64-linux-gnu/libpq.so.5(0x7f704caeae65) [0x7f704caeae65]
/usr/lib/x86_64-linux-gnu/libpq.so.5(0x7f704caeaee5) [0x7f704caeaee5]
/usr/lib/x86_64-linux-gnu/libpq.so.5(0x7f704caf5b49) [0x7f704caf5b49]
/usr/lib/x86_64-linux-gnu/libpq.so.5(PQisBusy+0x3d) [0x7f704caec40d]
/tmp/bundler-cache/2.7.8/ruby/2.7.0/gems/pg-1.5.3/lib/pg_ext.so(gvl_PQisBusy_skeleton+0xc) [0x7f704cb32afc] gvl_wrappers.c:14
/usr/local/lib/libruby.so.2.7(rb_nogvl+0x93) [0x7f70509b47b3] thread.c:1474
/tmp/bundler-cache/2.7.8/ruby/2.7.0/gems/pg-1.5.3/lib/pg_ext.so(gvl_PQisBusy+0x28) [0x7f704cb33288] gvl_wrappers.c:16
/tmp/bundler-cache/2.7.8/ruby/2.7.0/gems/pg-1.5.3/lib/pg_ext.so(get_result_readable+0x9) [0x7f704cb36679] pg_connection.c:3005
/tmp/bundler-cache/2.7.8/ruby/2.7.0/gems/pg-1.5.3/lib/pg_ext.so(wait_socket_readable+0x1a5) [0x7f704cb39575] pg_connection.c:2395
/tmp/bundler-cache/2.7.8/ruby/2.7.0/gems/pg-1.5.3/lib/pg_ext.so(pgconn_async_get_last_result+0x52) [0x7f704cb3a942] pg_connection.c:3111
/tmp/bundler-cache/2.7.8/ruby/2.7.0/gems/pg-1.5.3/lib/pg_ext.so(pgconn_async_exec+0x2c) [0x7f704cb3c2cc] pg_connection.c:3260
[0x7f70509de782]
/usr/local/lib/libruby.so.2.7(vm_sendish+0x76) [0x7f70509d9486] vm_insnhelper.c:4023
[0x7f70509e9264]
[0x7f70509eea9b]
/usr/local/lib/libruby.so.2.7(rb_vm_call0+0xbf) [0x7f70509f274f] vm_eval.c:52
/usr/local/lib/libruby.so.2.7(rb_vm_call_kw+0x68) [0x7f70509f2b48] vm_eval.c:268
/usr/local/lib/libruby.so.2.7(rb_funcallv_kw+0x11e) [0x7f70509f876e] vm_eval.c:392
/usr/local/lib/libruby.so.2.7(rb_class_s_new+0x4c) [0x7f7050904b5c] object.c:2152
[0x7f70509de782]
/usr/local/lib/libruby.so.2.7(vm_sendish+0x76) [0x7f70509d9486] vm_insnhelper.c:4023
[0x7f70509e9264]
[0x7f70509eea9b]
/usr/local/lib/libruby.so.2.7(rb_vm_call0+0xbf) [0x7f70509f274f] vm_eval.c:52
/usr/local/lib/libruby.so.2.7(rb_vm_call_kw+0x68) [0x7f70509f2b48] vm_eval.c:268
/usr/local/lib/libruby.so.2.7(rb_funcallv_kw+0x11e) [0x7f70509f876e] vm_eval.c:392
/usr/local/lib/libruby.so.2.7(rb_class_s_new+0x4c) [0x7f7050904b5c] object.c:2152
[0x7f70509de782]
/usr/local/lib/libruby.so.2.7(vm_sendish+0x76) [0x7f70509d9486] vm_insnhelper.c:4023
[0x7f70509e9264]
[0x7f70509eea9b]
/usr/local/lib/libruby.so.2.7(yield_under+0x1be) [0x7f70509fa4de] vm.c:1171
[0x7f70509de782]
/usr/local/lib/libruby.so.2.7(vm_call_opt_send+0x2bd) [0x7f70509f115d] vm_insnhelper.c:2661
/usr/local/lib/libruby.so.2.7(vm_sendish+0x76) [0x7f70509d9486] vm_insnhelper.c:4023
[0x7f70509e92d3]
[0x7f70509eea9b]
/usr/local/lib/libruby.so.2.7(rb_yield+0x75) [0x7f70509fada5] vm.c:1179
/usr/local/lib/libruby.so.2.7(rb_ary_each+0x2c) [0x7f70507fef1c] array.c:2135
/usr/local/lib/libruby.so.2.7(rb_ary_each) array.c:2129
[0x7f70509de782]
/usr/local/lib/libruby.so.2.7(vm_sendish+0x76) [0x7f70509d9486] vm_insnhelper.c:4023
[0x7f70509e92d3]
[0x7f70509eea9b]
/usr/local/lib/libruby.so.2.7(catch_i+0x58) [0x7f70509fab28] vm.c:1179
/usr/local/lib/libruby.so.2.7(vm_catch_protect+0xb4) [0x7f70509e2f44] vm_eval.c:2310
/usr/local/lib/libruby.so.2.7(rb_catch_obj+0x2a) [0x7f70509e303a] vm_eval.c:2336
[0x7f70509de782]
/usr/local/lib/libruby.so.2.7(vm_sendish+0x76) [0x7f70509d9486] vm_insnhelper.c:4023
[0x7f70509e92d3]
[0x7f70509eea9b]
/usr/local/lib/libruby.so.2.7(rb_yield+0x75) [0x7f70509fada5] vm.c:1179
/usr/local/lib/libruby.so.2.7(rb_ary_each+0x2c) [0x7f70507fef1c] array.c:2135
/usr/local/lib/libruby.so.2.7(rb_ary_each) array.c:2129
[0x7f70509de782]
/usr/local/lib/libruby.so.2.7(vm_sendish+0x76) [0x7f70509d9486] vm_insnhelper.c:4023
[0x7f70509e92d3]
[0x7f70509eea9b]
/usr/local/lib/libruby.so.2.7(rb_vm_call0+0xbf) [0x7f70509f274f] vm_eval.c:52
/usr/local/lib/libruby.so.2.7(rb_vm_call_kw+0x68) [0x7f70509f2b48] vm_eval.c:268
[0x7f70509352f0]
/usr/local/lib/libruby.so.2.7(vm_yield_with_cfunc+0xed) [0x7f70509e540d] vm_insnhelper.c:3220
/usr/local/lib/libruby.so.2.7(vm_invoke_ifunc_block+0x69) [0x7f70509e54d9] vm_insnhelper.c:3381
/usr/local/lib/libruby.so.2.7(vm_sendish+0x76) [0x7f70509d9486] vm_insnhelper.c:4023
[0x7f70509e9264]
[0x7f70509eea9b]
[0x7f70509b28f4]
[0x7f70509b4e2c]
/usr/local/lib/libruby.so.2.7(thread_start_func_1+0xba) [0x7f70509b53da] thread_pthread.c:969
/lib/x86_64-linux-gnu/libpthread.so.0(start_thread+0xd7) [0x7f70505b3ea7]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f) [0x7f70506e7a2f]

@larskanis
Copy link
Collaborator

Both ruby versions crash on PQisBusy. This function has a single argument, which is the PQconn pointer. For me it looks like the PQconn was released for some reason or points to some invalid memory for some reason. I don't have an idea why this should happen.

The only other reason for a crash, I could imagine, is that the PQconn is used concurrently by two threads, but that should lead to some invalid message warnings in addition to the segfault.

It could help to reproduce the segfault in a gdb session. On modern Linux distributions like Ubuntu-23.04, gdb asks for download of debug symbols of system libraries, so that we could see, within which function and source line libpq crashes.

Beside this I don't have a good idea for now. So far it's the only bug report of this kind.

@Meekohi
Copy link

Meekohi commented Jun 30, 2023

Same issue here.

@TcThinh
Copy link

TcThinh commented Jul 4, 2023

Same issue:

/usr/share/rvm/gems/ruby-3.0.4/gems/pg-1.4.5/lib/pg/connection.rb:626: [BUG] Segmentation fault at 0x00007fb3e97f3140
ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [x86_64-linux]

@dhurba87
Copy link

dhurba87 commented Jul 12, 2023

similar issue with ruby 3.0.x and pg 1.5.3

Started GET "/" for ::1 at 2023-07-12 20:33:00 +0545
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/pg-1.5.3/lib/pg/connection.rb:690: [BUG] Segmentation fault at 0x00000001041a0ae0
ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [arm64-darwin22]

-- Control frame information -----------------------------------------------
c:0084 p:---- s:0595 e:000594 CFUNC  :connect_poll
c:0083 p:0543 s:0591 e:000590 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/pg-1.5.3/lib/pg/connection.rb:690
c:0082 p:0354 s:0578 e:000577 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/pg-1.5.3/lib/pg/connection.rb:824
c:0081 p:0007 s:0567 e:000566 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/pg-1.5.3/lib/pg/connection.rb:759
c:0080 p:0019 s:0561 e:000560 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/pg-1.5.3/lib/pg.rb:63
c:0079 p:0013 s:0555 e:000554 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/postgres
c:0078 p:0112 s:0549 e:000547 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/postgres [FINISH]
c:0077 p:---- s:0541 e:000540 CFUNC  :public_send
c:0076 p:0021 s:0535 e:000534 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/abstract
c:0075 p:0021 s:0531 e:000530 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/abstract
c:0074 p:0014 s:0527 e:000526 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/abstract
c:0073 p:0012 s:0521 e:000520 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/abstract
c:0072 p:0011 s:0515 e:000513 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/abstract
c:0071 p:0021 s:0509 e:000505 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/abstract
c:0070 p:0291 s:0502 e:000501 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/abstract
c:0069 p:0014 s:0492 e:000491 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_handling.rb:313
c:0068 p:0003 s:0488 e:000487 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_handling.rb:280
c:0067 p:0015 s:0484 e:000483 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/migration.rb:613
c:0066 p:0004 s:0480 e:000478 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/migration.rb:608
c:0065 p:0012 s:0473 e:000472 BLOCK  /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/migration.rb:590 [FINISH]
c:0064 p:---- s:0470 e:000469 CFUNC  :synchronize
c:0063 p:0006 s:0466 e:000465 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/migration.rb:589
c:0062 p:0008 s:0461 e:000460 BLOCK  /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/actionpack-7.0.5.1/lib/action_dispatch/middleware/callbacks.rb:27
c:0061 p:0024 s:0458 e:000457 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activesupport-7.0.5.1/lib/active_support/callbacks.rb:99
c:0060 p:0009 s:0449 e:000448 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/actionpack-7.0.5.1/lib/action_dispatch/middleware/callbacks.rb:26
c:0059 p:0016 s:0442 e:000441 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/actionpack-7.0.5.1/lib/action_dispatch/middleware/executor.rb:14
c:0058 p:0033 s:0433 e:000432 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/actionpack-7.0.5.1/lib/action_dispatch/middleware/actionable_except
c:0057 p:0007 s:0427 e:000426 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/ddtrace-1.3.0/lib/datadog/tracing/contrib/rails/middlewares.rb:19
c:0056 p:0007 s:0420 e:000419 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/better_errors-2.10.1/lib/better_errors/middleware.rb:87
c:0055 p:0025 s:0414 e:000413 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/better_errors-2.10.1/lib/better_errors/middleware.rb:82
c:0054 p:0012 s:0409 e:000408 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/better_errors-2.10.1/lib/better_errors/middleware.rb:60
c:0053 p:0026 s:0404 e:000403 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/actionpack-7.0.5.1/lib/action_dispatch/middleware/debug_exceptions.
c:0052 p:0007 s:0393 e:000392 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/web-console-4.2.0/lib/web_console/middleware.rb:132
c:0051 p:0069 s:0387 e:000386 BLOCK  /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/web-console-4.2.0/lib/web_console/middleware.rb:28 [FINISH]
c:0050 p:---- s:0377 e:000376 CFUNC  :catch
c:0049 p:0006 s:0372 e:000371 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/web-console-4.2.0/lib/web_console/middleware.rb:17
c:0048 p:0007 s:0365 e:000364 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/honeycomb-beeline-2.11.0/lib/honeycomb/integrations/rack.rb:80
c:0047 p:0008 s:0358 e:000357 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/honeycomb-beeline-2.11.0/lib/honeycomb/integrations/rails.rb:94
c:0046 p:0058 s:0349 E:001f38 BLOCK  /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/honeycomb-beeline-2.11.0/lib/honeycomb/integrations/rack.rb:53
c:0045 p:0035 s:0341 e:000340 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/honeycomb-beeline-2.11.0/lib/honeycomb/client.rb:65
c:0044 p:0032 s:0331 E:001ef0 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/honeycomb-beeline-2.11.0/lib/honeycomb/integrations/rack.rb:37
c:0043 p:0026 s:0325 e:000324 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/actionpack-7.0.5.1/lib/action_dispatch/middleware/show_exceptions.r
c:0042 p:0049 s:0318 E:002460 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/railties-7.0.5.1/lib/rails/rack/logger.rb:40
c:0041 p:0008 s:0306 e:000305 BLOCK  /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/railties-7.0.5.1/lib/rails/rack/logger.rb:25
c:0040 p:0004 s:0303 e:000302 BLOCK  /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activesupport-7.0.5.1/lib/active_support/tagged_logging.rb:99
c:0039 p:0012 s:0300 e:000299 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activesupport-7.0.5.1/lib/active_support/tagged_logging.rb:37
c:0038 p:0015 s:0294 e:000293 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activesupport-7.0.5.1/lib/active_support/tagged_logging.rb:99
c:0037 p:0039 s:0288 e:000287 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/railties-7.0.5.1/lib/rails/rack/logger.rb:25
c:0036 p:0040 s:0282 e:000281 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/ahoy_matey-4.2.1/lib/ahoy/engine.rb:22
c:0035 p:0038 s:0277 e:000276 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/sprockets-rails-3.4.2/lib/sprockets/rails/quiet_assets.rb:13
c:0034 p:0052 s:0272 e:000271 METHOD /Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/actionpack-7.0.5.1/lib/action_dispatch/middleware/remote_ip.rb:93

-- Ruby level backtrace information ----------------------------------------
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/puma-5.6.6/lib/puma/thread_pool.rb:147:in `block in spawn_thread'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/puma-5.6.6/lib/puma/server.rb:443:in `process_client'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/puma-5.6.6/lib/puma/request.rb:76:in `handle_request'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/puma-5.6.6/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/puma-5.6.6/lib/puma/request.rb:77:in `block in handle_request'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/puma-5.6.6/lib/puma/configuration.rb:252:in `call'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/railties-7.0.5.1/lib/rails/engine.rb:530:in `call'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/rack-proxy-0.7.6/lib/rack/proxy.rb:87:in `call'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/webpacker-5.4.4/lib/webpacker/dev_server_proxy.rb:25:in `perform_request'
...
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/migration.rb:608:in `build_watcher'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/migration.rb:613:in `connection'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_handling.rb:280:in `connection'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_handling.rb:313:in `retrieve_connection'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/abstract/connection_handler.rb:211:in `retrieve_connection'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in `connection'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:341:in `checkout'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:640:in `acquire_connection'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:679:in `try_to_checkout_new_connection'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:700:in `checkout_new_connection'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in `new_connection'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in `public_send'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:78:in `new_client'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/pg-1.5.3/lib/pg.rb:63:in `connect'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/pg-1.5.3/lib/pg/connection.rb:759:in `new'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/pg-1.5.3/lib/pg/connection.rb:824:in `connect_to_hosts'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/pg-1.5.3/lib/pg/connection.rb:690:in `async_connect_or_reset'
/Users/dhurbabaral/code/forem/vendor/bundle/ruby/3.0.0/gems/pg-1.5.3/lib/pg/connection.rb:690:in `connect_poll'

Update:
export PGGSSENCMODE="disable" worked for me ref: #538 (comment)

@joshleblanc
Copy link

joshleblanc commented Aug 3, 2023

FYI, you can also use ?gssencmode=disable in the connection url param to disable this, or set gssencmode: disable right in config/database.yml.

Edit: while this helped, it didn't fix it in all cases

@BrijeshSajeev
Copy link

BrijeshSajeev commented Jun 28, 2024

Hi, We're facing a Segmentation fault with ruby 2.7.4 and pg 1.4.6 in a rails application (v6.1.7) in the mx-linux

/home/brijesh/.rvm/gems/ruby-2.7.4@referalgps/gems/pg-1.4.6/lib/pg/connection.rb:627: [BUG] Segmentation fault at 0x0000000000000000
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants