Closed mathieumahe closed 1 year ago
Thanks, the C-level backtrace is interesting, I'll have a look to see if I spot something wrong.
Tell me if you need more information
So if you can, here's what would help:
redis-client
.Interestingly, rb_ary_store
doesn't check the argument is an Array, perhaps that is what is happening here:
void
rb_ary_store(VALUE ary, long idx, VALUE val)
{
long len = RARRAY_LEN(ary);
if (idx < 0) {
idx += len;
if (idx < 0) {
rb_raise(rb_eIndexError, "index %ld too small for array; minimum: %ld",
idx - len, -len);
}
}
else if (idx >= ARY_MAX_SIZE) {
rb_raise(rb_eIndexError, "index %ld too big", idx);
}
rb_ary_modify(ary);
if (idx >= ARY_CAPA(ary)) {
ary_double_capa(ary, idx);
}
if (idx > len) {
ary_mem_clear(ary, len, idx - len + 1);
}
if (idx >= len) {
ARY_SET_LEN(ary, idx + 1);
}
ARY_SET(ary, idx, val);
}
This code used to work correctly.
Does this mean you recently upgraded? A possible cause for this would be https://github.com/redis-rb/redis-client/commit/873cef78b34c54ca54efccf226fd0a0cdaa18956 which shipped with v0.14.0
.
I pushed https://github.com/redis-rb/redis-client/commit/1ab081c1d0e47df5d55e011c9390c70b2eef6731 on main
which could explain that crash. Please try it out.
Does this mean you recently upgraded? A possible cause for this would be https://github.com/redis-rb/redis-client/commit/873cef78b34c54ca54efccf226fd0a0cdaa18956 which shipped with v0.14.0.
Last week, I was in v0.14.1
but my app Segfaulted, (same error than above), so I upgraded to last version to see if the bug was solved, but I continued to see the error a couple of times.
And from what I see in my git, 0.14.1 was my first version for this gem.
My app starts Segfaulting without upgrading the version of the gem (if I remember correctly...).
I pushed https://github.com/redis-rb/redis-client/commit/1ab081c1d0e47df5d55e011c9390c70b2eef6731 on main which could explain that crash. Please try it out.
Sure, thanks for the super quick answer !
In the meantime, I will launch a small reproduction script to see if I found the same error with the 0.17.0 version
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem 'rails', '7.0.6'
gem 'bootsnap', '1.16.0', require: false
gem 'hiredis-client', '0.17.0'
end
ENV['BOOTSNAP_CACHE_DIR'] = '~/.bootsnap'
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
Thread.new do
conn = RedisClient.new(reconnect_attempts: [0.2, 0.8, 2]).pubsub
conn.call('subscribe', 'feature_flags')
loop do
next unless message = conn.next_event(20)
p message
end
end
sleep
My app with your last commit just segfault again.
ruby 3.2.2 (2023-03-30 revision e51014f9c0) +YJIT [x86_64-darwin22]
-- Crash Report log information --------------------------------------------
See Crash Report log file in one of the following locations:
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
Don't forget to include the above Crash Report log file in bug reports.
-- Control frame information -----------------------------------------------
c:0007 p:---- s:0034 e:000033 CFUNC :_read
c:0006 p:0028 s:0030 e:000029 METHOD /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/hiredis-client/lib/redis_client
c:0005 p:0023 s:0023 e:000022 METHOD /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/lib/redis_client.rb:458
c:0004 p:0007 s:0018 e:000017 BLOCK /Users/mathieu/Documents/rbean/rbean/lib/sse_manager.rb:89 [FINISH]
c:0003 p:---- s:0011 e:000010 CFUNC :loop
c:0002 p:0035 s:0007 E:000fb8 BLOCK /Users/mathieu/Documents/rbean/rbean/lib/sse_manager.rb:88 [FINISH]
c:0001 p:---- s:0003 e:000002 DUMMY [FINISH]
-- Ruby level backtrace information ----------------------------------------
/Users/mathieu/Documents/rbean/rbean/lib/sse_manager.rb:88:in `block in listen'
/Users/mathieu/Documents/rbean/rbean/lib/sse_manager.rb:88:in `loop'
/Users/mathieu/Documents/rbean/rbean/lib/sse_manager.rb:89:in `block (2 levels) in listen'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/lib/redis_client.rb:458:in `next_event'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/hiredis-client/lib/redis_client/hiredis_connection.rb:95:in `read'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/hiredis-client/lib/redis_client/hiredis_connection.rb:95:in `_read'
-- Machine register context ------------------------------------------------
rax: 0x0000000000000024 rbx: 0x0000000000000002 rcx: 0x0000000000000000
rdx: 0x0000000000000000 rdi: 0x0000000115781f50 rsi: 0x000000011712ef68
rbp: 0x000070000d75c180 rsp: 0x000070000d75c150 r8: 0x0000000000004002
r9: 0x00000001165ff0c8 r10: 0x0000000000001604 r11: 0x000000011652fca3
r12: 0x0000000000000000 r13: 0x000070000d75c218 r14: 0x0000000000000000
r15: 0x000000011712ef68 rip: 0x0000000117adafed rfl: 0x0000000000010206
-- C level backtrace information -------------------------------------------
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_vm_bugreport+0x7c4) [0x10571a444]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_bug_for_fatal_signal+0x1d9) [0x105518f59]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(sigsegv+0x5b) [0x1056674ab]
/usr/lib/system/libsystem_platform.dylib(_sigtramp+0x1d) [0x7ff8180d9c1d]
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/hiredis-client/lib/redis_client/hiredis_connection.bundle(reply_append+0x1d) [0x117adafed]
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/hiredis-client/lib/redis_client/hiredis_connection.rb:95: [BUG] Segmentation fault at 0x0000000000000000
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/hiredis-client/lib/redis_client/hiredis_connection.bundle(redisReaderGetReply+0xb4d) [0x117ae65fd]
ruby 3.2.2 (2023-03-30 revision e51014f9c0) +YJIT [x86_64-darwin22]
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/hiredis-client/lib/redis_client/hiredis_connection.bundle(redisGetReplyFromReader+0x19) [0x117ade629]
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/hiredis-client/lib/redis_client/hiredis_connection.bundle(hiredis_read+0x1b9) [0x117ada259]
-- Crash Report log information --------------------------------------------
See Crash Report log file in one of the following locations:
-- Other runtime information -----------------------------------------------
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
* Loaded script: bin/rails
for more details.
Don't forget to include the above Crash Report log file in bug reports.
* Loaded features:
-- Control frame information -----------------------------------------------
0 enumerator.so
c:0007 p:---- s:0034 e:000033 CFUNC :_read
1 thread.rb
c:0006 p:0028 s:0030 e:000029 METHOD /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/hiredis-client/lib/redis_client
2 fiber.so
c:0005 p:0023 s:0023 e:000022 METHOD /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/lib/redis_client.rb:458
3 rational.so
c:0004 p:0007 s:0018 e:000017 BLOCK /Users/mathieu/Documents/rbean/rbean/lib/sse_manager.rb:89 [FINISH]
4 complex.so
c:0003 p:---- s:0011 e:000010 CFUNC :loop
5 ruby2_keywords.rb
c:0002 p:0035 s:0007 E:001188 BLOCK /Users/mathieu/Documents/rbean/rbean/lib/sse_manager.rb:88 [FINISH]
6 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/x86_64-darwin22/enc/encdb.bundle
c:0001 p:---- s:0003 e:000002 DUMMY [FINISH]
7 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/x86_64-darwin22/enc/trans/transdb.bundle
8 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/x86_64-darwin22/rbconfig.rb
-- Ruby level backtrace information ----------------------------------------
9 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/compatibility.rb
/Users/mathieu/Documents/rbean/rbean/lib/sse_manager.rb:88:in `block in listen'
10 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/defaults.rb
/Users/mathieu/Documents/rbean/rbean/lib/sse_manager.rb:88:in `loop'
11 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/deprecate.rb
/Users/mathieu/Documents/rbean/rbean/lib/sse_manager.rb:89:in `block (2 levels) in listen'
12 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/errors.rb
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/lib/redis_client.rb:458:in `next_event'
13 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/unknown_command_spell_checker.rb
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/hiredis-client/lib/redis_client/hiredis_connection.rb:95:in `read'
14 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/exceptions.rb
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/hiredis-client/lib/redis_client/hiredis_connection.rb:95:in `_read'
15 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/basic_specification.rb
16 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/stub_specification.rb
-- Machine register context ------------------------------------------------
17 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/platform.rb
rax: 0x4004080040040800 rbx: 0x000000010d5cb000 rcx: 0x0000000000000008
18 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/util/list.rb
rdx: 0x0000000065005356 rdi: 0x000000010d5c0000 rsi: 0x0000000065005356
19 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/version.rb
rbp: 0x0000700008c22100 rsp: 0x0000700008c22100 r8: 0x0000000000004002
20 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/requirement.rb
r9: 0x0000000120d9d088 r10: 0x0000000000001604 r11: 0x0000000120ddb1a3
21 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/specification.rb
r12: 0x0000000065005356 r13: 0x0ffffffffffffffe r14: 0x000000011deca6d0
22 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/util.rb
r15: 0x000000000000005d rip: 0x000000010de1501e rfl: 0x0000000000010206
23 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/dependency.rb
24 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_gem.rb
-- C level backtrace information -------------------------------------------
25 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/x86_64-darwin22/monitor.bundle
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_vm_bugreport+0x7c4) [0x10dffa444]
26 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/monitor.rb
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_bug_for_fatal_signal+0x1d9) [0x10ddf8f59]
27 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems.rb
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(sigsegv+0x5b) [0x10df474ab]
28 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/path_support.rb
/usr/lib/system/libsystem_platform.dylib(_sigtramp+0x1d) [0x7ff8180d9c1d]
29 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/error_highlight/version.rb
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_gc_obj_slot_size+0xe) [0x10de1501e]
30 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/error_highlight/base.rb
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_ary_store+0xca) [0x10dd4bdba]
31 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/error_highlight/formatter.rb
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/hiredis-client/lib/redis_client/hiredis_connection.bundle(reply_append+0x73) [0x12039b043]
32 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/error_highlight/core_ext.rb
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/hiredis-client/lib/redis_client/hiredis_connection.bundle(redisReaderGetReply+0xb4d) [0x1203a65fd]
33 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/error_highlight.rb
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/hiredis-client/lib/redis_client/hiredis_connection.bundle(redisGetReplyFromReader+0x19) [0x12039e629]
34 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/did_you_mean/version.rb
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-1ab081c1d0e4/hiredis-client/lib/redis_client/hiredis_connection.bundle(hiredis_read+0x1b9) [0x12039a259]
35 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/did_you_mean/core_ext/name_error.rb
36 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/did_you_mean/levenshtein.rb
-- Other runtime information -----------------------------------------------
37 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/did_you_mean/jaro_winkler.rb
38 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/did_you_mean/spell_checker.rb
* Loaded script: bin/rails
39 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
40 /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/3.2.0/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
I just submit a form in a part of the app that doesn't seem related. Is it possible that this segfault is linked to YJIT ? I can disable it to see if the bug reappear.
Is it possible that this segfault is linked to YJIT
It's not impossible but unlikely.
There are a couple known YJIT bugs in 3.2.2 that can cause things like instance variable to be corrupted. These bugs have been backported to the 3_2 stable branch, but will only be out with 3.2.3.
If you don't mind disabling YJIT, that would at least rule this out.
I'll have another look. Perhaps add a type check so that at least we'll have more information about what is going on.
Could you try this branch please: https://github.com/redis-rb/redis-client/tree/hiredis-type-check ?
It adds more debug information, when you'll run into this bug it will print the object that is supposed to be an array.
Ideally you retry a few times so that we can see if the unexpected object is consistent or random. Thanks in advance.
I cannot start the app anymore :
(Mathieu@Harmony 22934)[rbean/rbean]RUBY_YJIT_ENABLE=1 bin/dev
started with pid 26724
started with pid 26725
started with pid 26726
yarn run v1.22.0
$ node build.js
[watch] build finished, watching for changes...
⚡ Done
[watch] build finished, watching for changes...
⚡ Done
[watch] build finished, watching for changes...
⚡ Done
[hiredis] Parent isn't a T_ARRAY index=1
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/hiredis-client/lib/redis_client/hiredis_connection.rb:90: [BUG] [hiredis] Invalid Parent (nested)
ruby 3.2.2 (2023-03-30 revision e51014f9c0) +YJIT [x86_64-darwin22]
-- Crash Report log information --------------------------------------------
See Crash Report log file in one of the following locations:
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
Don't forget to include the above Crash Report log file in bug reports.
-- Control frame information -----------------------------------------------
c:0013 p:---- s:0073 e:000072 CFUNC :_read
c:0012 p:0012 s:0069 e:000068 METHOD /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/hiredis-client/lib/redis_client
c:0011 p:0020 s:0062 e:000061 BLOCK /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client/connection_mix [FINISH]
c:0010 p:---- s:0056 e:000055 CFUNC :times
c:0009 p:0040 s:0052 e:000051 METHOD /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client/connection_mix
c:0008 p:0008 s:0043 e:000042 BLOCK /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client.rb:713
c:0007 p:0004 s:0040 e:000039 METHOD /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client/middlewares.rb
c:0006 p:0123 s:0034 e:000033 METHOD /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client.rb:712
c:0005 p:0019 s:0027 e:000026 METHOD /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client.rb:674
c:0004 p:0058 s:0023 e:000022 METHOD /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client.rb:641
c:0003 p:0005 s:0013 e:000011 METHOD /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client.rb:207
c:0002 p:0008 s:0007 e:000006 BLOCK /Users/mathieu/Documents/rbean/rbean/lib/sse_manager.rb:85 [FINISH]
c:0001 p:---- s:0003 e:000002 DUMMY [FINISH]
-- Ruby level backtrace information ----------------------------------------
/Users/mathieu/Documents/rbean/rbean/lib/sse_manager.rb:85:in `block in listen'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client.rb:207:in `pubsub'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client.rb:641:in `ensure_connected'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client.rb:674:in `raw_connection'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client.rb:712:in `connect'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client/middlewares.rb:16:in `call'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client.rb:713:in `block in connect'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client/connection_mixin.rb:49:in `call_pipelined'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client/connection_mixin.rb:49:in `times'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/lib/redis_client/connection_mixin.rb:51:in `block in call_pipelined'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/hiredis-client/lib/redis_client/hiredis_connection.rb:90:in `read'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/hiredis-client/lib/redis_client/hiredis_connection.rb:90:in `_read'
-- C level backtrace information -------------------------------------------
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_vm_bugreport+0x7c4) [0x100de8444]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_bug_without_die+0x15c) [0x100be6c7c]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_bug+0x72) [0x100f0917d]
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/hiredis-client/lib/redis_client/hiredis_connection.bundle(reply_append.cold.2+0x39) [0x1131c8389]
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/hiredis-client/lib/redis_client/hiredis_connection.bundle(reply_append+0x118) [0x1131baf58]
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/hiredis-client/lib/redis_client/hiredis_connection.bundle(redisReaderGetReply+0xe30) [0x1131c67c0]
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/hiredis-client/lib/redis_client/hiredis_connection.bundle(redisGetReplyFromReader+0x19) [0x1131be509]
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ae1159246a4d/hiredis-client/lib/redis_client/hiredis_connection.bundle(hiredis_read+0x1b9) [0x1131ba0c9]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(vm_call_cfunc_with_frame+0x15d) [0x100ddbe9d]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(vm_sendish+0x4c5) [0x100dde335]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(vm_exec_core+0x2bb0) [0x100dbc190]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_vm_exec+0xc1c) [0x100dd171c]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(invoke_block_from_c_bh+0x70e) [0x100de2d4e]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_yield_1+0x74) [0x100dc9114]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(int_dotimes+0x178) [0x100c89938]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(vm_call_cfunc_with_frame+0x15d) [0x100ddbe9d]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(vm_sendish+0x4c5) [0x100dde335]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(vm_exec_core+0x2b5b) [0x100dbc13b]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_vm_exec+0xc1c) [0x100dd171c]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_vm_invoke_proc+0xd3a) [0x100dcf35a]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(thread_do_start_proc+0x2ab) [0x100d8732b]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(thread_start_func_2+0x4fa) [0x100d8697a]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(thread_start_func_1+0x16c) [0x100d8623c]
/usr/lib/system/libsystem_pthread.dylib(_pthread_start+0x7d) [0x7ff8180af259]
-- Other runtime information -----------------------------------------------
Same with ou without YJIT.
The rb_p(parent);
doesn't seem to print anything as you can see. Probably nil ? (I'm not sur how to compile the C extension so I can try debugging on my side)
I cannot start the app anymore :
Sorry, that's my bad, my branch wasn't accounting for something.
Please pull the branch again.
I just segfaulted again and nothing was print. :/
Oh wow. That would suggest the object is indeed an array, but then I have no idea why it would crash 🤔 .
I'm afraid at this stage I'll need a standalone repro script to debug this further.
No problem!
My repro script didn't segfault yet. In the meantime I will try without YJIT and without Jemalloc (the last 2 things I changed) see if I can find any differencies.
Thanks for your help and I'll keep you updated
The small script has just segfaulted.
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.rb:95: [BUG] Segmentation fault at 0x0000000000000000
ruby 3.2.2 (2023-03-30 revision e51014f9c0) +YJIT [x86_64-darwin22]
-- Crash Report log information --------------------------------------------
See Crash Report log file in one of the following locations:
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
Don't forget to include the above Crash Report log file in bug reports.
-- Control frame information -----------------------------------------------
c:0007 p:---- s:0031 e:000030 CFUNC :_read
c:0006 p:0028 s:0027 e:000026 METHOD /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.rb:95
c:0005 p:0023 s:0020 e:000019 METHOD /Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.17.0/lib/redis_client.rb:458
c:0004 p:0007 s:0015 e:000014 BLOCK repro_code.rb:17 [FINISH]
c:0003 p:---- s:0011 e:000010 CFUNC :loop
c:0002 p:0023 s:0007 e:000006 BLOCK repro_code.rb:16 [FINISH]
c:0001 p:---- s:0003 e:000002 DUMMY [FINISH]
-- Ruby level backtrace information ----------------------------------------
repro_code.rb:16:in `block in <main>'
repro_code.rb:16:in `loop'
repro_code.rb:17:in `block (2 levels) in <main>'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.17.0/lib/redis_client.rb:458:in `next_event'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.rb:95:in `read'
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.rb:95:in `_read'
-- Machine register context ------------------------------------------------
rax: 0x0000000101f948c0 rbx: 0x0000000000000000 rcx: 0x0000000000000000
rdx: 0xffffffffe5894855 rdi: 0x0000000000000000 rsi: 0xffffffffe5894855
rbp: 0x000070000d7d4140 rsp: 0x000070000d7d4110 r8: 0x0000000000004002
r9: 0x000000010ce65648 r10: 0x0000000000001604 r11: 0x0000000118e310c5
r12: 0x0000000000000000 r13: 0x000070000d7d4208 r14: 0x000000011d7ef950
r15: 0x000000011d7ef950 rip: 0x0000000101d4dd07 rfl: 0x0000000000010246
-- C level backtrace information -------------------------------------------
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_vm_bugreport+0x7c4) [0x101ffc444]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_bug_for_fatal_signal+0x1d9) [0x101dfaf59]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(sigsegv+0x5b) [0x101f494ab]
/usr/lib/system/libsystem_platform.dylib(_sigtramp+0x1d) [0x7ff8180d9c1d]
/Users/mathieu/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_ary_store+0x17) [0x101d4dd07]
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.bundle(reply_append+0x73) [0x11f63b043]
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.bundle(redisReaderGetReply+0xb4d) [0x11f6465fd]
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.bundle(redisGetReplyFromReader+0x19) [0x11f63e629]
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.bundle(hiredis_read+0x1a9) [0x11f63a259]
Could you share the reproduction script and steps?
How long did it take to happen?
I suppose it's the script in https://github.com/redis-rb/redis-client/issues/141#issuecomment-1715474723, but not sure what the event sent look like.
Yes, the script is above.
I launched it like that RUBY_YJIT_ENABLE=1 ruby repro_code.rb
, pretty much 24 hours ago (but my macbook on sleep for a bit part of those 24 hours).
It didn't received any events.
Not ideal to test :/
Yeah, I tried various versions of that without success:
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem 'hiredis-client', path: "/Users/byroot/src/github.com/redis-rb/redis-client"
end
require 'hiredis-client'
p RedisClient.default_driver
conn = RedisClient.new(reconnect_attempts: [0.2, 0.8, 2]).pubsub
conn.call('subscribe', 'feature_flags')
loop do
GC.stress = true
message = conn.next_event(0.3)
GC.stress = false
print '.'
end
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem 'hiredis-client', path: "/Users/byroot/src/github.com/redis-rb/redis-client"
end
require 'hiredis-client'
p RedisClient.default_driver
#
thr = Thread.new do
conn2 = RedisClient.new(reconnect_attempts: [0.2, 0.8, 2])
p conn2
100_000.times do
conn2.call("publish", "feature_flags", "Hello" * 1000)
sleep 0.01
end
end
conn = RedisClient.new(reconnect_attempts: [0.2, 0.8, 2]).pubsub
conn.call('subscribe', 'feature_flags')
loop do
GC.stress = true
message = conn.next_event(20)
GC.stress = false
print '.'
end
I'm sorry, but without a repro I can't dig this further.
I'd recommend making the necessary so that you get a core dump next time, so that at least you can use lldb
to grab a few debug informations.
Ok, I'll check with the core dumps.
JFYI, I got another segfault from my main app (I'm pretty sure it's linked with YJIT now, or at least it makes the segfault more obvious in a way), and it printed :
[hiredis] Stack isn't a T_ARRAY index=405382272
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ebb57c2ade1d/hiredis-client/lib/redis_client/hiredis_connection.rb:95: [BUG] Segmentation fault at 0x0000000000020038
[hiredis] Stack isn't a T_ARRAY index=273580032
ruby 3.2.2 (2023-03-30 revision e51014f9c0) +YJIT [x86_64-darwin22]
/Users/mathieu/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/redis-client-ebb57c2ade1d/hiredis-client/lib/redis_client/hiredis_connection.rb:95: [BUG] Segmentation fault at 0x0000000000020038
Thanks for your help since the beginning and sorry to have nothing easier for you!
[hiredis] Stack isn't a T_ARRAY index=405382272
That is very interesting, thank you.
So there is two weird stuff here. First the Array we created is no longer an array, so it wasn't marked or wasn't pined, that is weird.
But also this index
makes 0 sense, there is no way a message would be this deep.
This is incredibly weird.
After several days without the YJIT, I had no segfaults, so I guess the error is not due to this gem. Maybe it's the memory corruption you were talking at the beginning of this thread.
I will try again after the ruby 3.3 release.
Anyway, thanks for your help!
Sounds good.
If you use ruby-build, rather than wait for Ruby 3.3 you can try https://github.com/Shopify/ruby-definitions
This is also happening in Sidekiq when a queue is paused or unpaused.
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.rb:90: [BUG] Segmentation fault at 0x0000000000020000
ruby 3.2.2 (2023-03-30 revision e51014f9c0) +YJIT [arm64-darwin21]
-- Crash Report log information --------------------------------------------
See Crash Report log file in one of the following locations:
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
Don't forget to include the above Crash Report log file in bug reports.
-- Control frame information -----------------------------------------------
c:0020 p:---- s:0094 e:000093 CFUNC :_read
c:0019 p:0012 s:0090 e:000089 METHOD /Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.rb:90
c:0018 p:0023 s:0083 e:000082 METHOD /Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.17.0/lib/redis_client.rb:458
c:0017 p:0005 s:0078 e:000077 BLOCK /Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-pro-7.1.5/lib/sidekiq/pro/config.rb:65 [FINISH]
c:0016 p:---- s:0072 e:000071 CFUNC :loop
c:0015 p:0004 s:0068 E:0021f8 METHOD /Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-pro-7.1.5/lib/sidekiq/pro/config.rb:64
c:0014 p:0025 s:0063 E:0021a0 BLOCK /Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-pro-7.1.5/lib/sidekiq/pro/config.rb:83
c:0013 p:0009 s:0058 E:001588 BLOCK /Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.1.5/lib/sidekiq/config.rb:163
c:0012 p:0004 s:0052 E:001930 BLOCK /Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:110 [FINISH]
c:0011 p:---- s:0049 e:000048 CFUNC :handle_interrupt
c:0010 p:0019 s:0044 E:002418 BLOCK /Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:109 [FINISH]
c:0009 p:---- s:0040 e:000039 CFUNC :handle_interrupt
c:0008 p:0015 s:0035 E:001a78 METHOD /Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:106
c:0007 p:0019 s:0030 E:0019d0 METHOD /Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.1.5/lib/sidekiq/config.rb:160
c:0006 p:0009 s:0026 E:001f58 METHOD /Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.1.5/lib/sidekiq/component.rb:28
c:0005 p:0014 s:0021 E:002170 METHOD /Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-pro-7.1.5/lib/sidekiq/pro/config.rb:78 [FINISH]
c:0004 p:---- s:0015 E:001ad0 IFUNC
c:0003 p:0002 s:0012 E:001f90 METHOD /Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.1.5/lib/sidekiq/component.rb:10
c:0002 p:0026 s:0006 E:001170 BLOCK /Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.1.5/lib/sidekiq/component.rb:19 [FINISH]
c:0001 p:---- s:0003 e:000002 DUMMY [FINISH]
-- Ruby level backtrace information ----------------------------------------
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.1.5/lib/sidekiq/component.rb:19:in `block in safe_thread'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.1.5/lib/sidekiq/component.rb:10:in `watchdog'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-pro-7.1.5/lib/sidekiq/pro/config.rb:78:in `listen'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.1.5/lib/sidekiq/component.rb:28:in `redis'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.1.5/lib/sidekiq/config.rb:160:in `redis'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:106:in `with'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:106:in `handle_interrupt'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:109:in `block in with'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:109:in `handle_interrupt'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:110:in `block (2 levels) in with'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.1.5/lib/sidekiq/config.rb:163:in `block in redis'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-pro-7.1.5/lib/sidekiq/pro/config.rb:83:in `block in listen'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-pro-7.1.5/lib/sidekiq/pro/config.rb:64:in `event_loop'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-pro-7.1.5/lib/sidekiq/pro/config.rb:64:in `loop'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-pro-7.1.5/lib/sidekiq/pro/config.rb:65:in `block in event_loop'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.17.0/lib/redis_client.rb:458:in `next_event'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.rb:90:in `read'
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.rb:90:in `_read'
-- Machine register context ------------------------------------------------
x0: 0x0000000000020000 x1: 0x0000000000000008 x2: 0x000000016fe58808
x3: 0x000000016fe58800 x4: 0x0000000000000000 x5: 0x0000600000c52ba8
x6: 0x0000000000000020 x7: 0x0000000200000000 x18: 0x0000000000000000
x19: 0x000000016fe58800 x20: 0x000000016fe58e78 x21: 0x000000016fe58808
x22: 0x0000000123df7ef0 x23: 0x0000000000000000 x24: 0x0000000000000000
x25: 0x0000000000000000 x26: 0x000000016fe58d80 x27: 0x000000000000000a
x28: 0x00000000ffffffff lr: 0x0000000100f79fe4 fp: 0x000000016fe58760
sp: 0x000000016fe58720
-- C level backtrace information -------------------------------------------
/Users/daniel/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_vm_bugreport+0x9a0) [0x10101720c]
/Users/daniel/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_bug_for_fatal_signal+0x160) [0x100e3b3a0]
/Users/daniel/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(sig_do_nothing+0x0) [0x100f75ac8]
/usr/lib/system/libsystem_platform.dylib(_sigtramp+0x38) [0x193ea34a4]
/Users/daniel/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(BSD_vfprintf+0x634) [0x100f79fe4]
/Users/daniel/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(BSD_vfprintf+0x634) [0x100f79fe4]
/Users/daniel/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(ruby_vsprintf0+0xb0) [0x100f7961c]
/Users/daniel/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_sprintf+0x60) [0x100f797dc]
/Users/daniel/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_error_frozen_object+0x9c) [0x100e3f96c]
/Users/daniel/.rbenv/versions/3.2.2/lib/libruby.3.2.dylib(rb_ary_store+0x208) [0x100daacdc]
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.bundle(reply_append+0x90) [0x12308da14]
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.bundle(redisReaderGetReply+0x914) [0x123098834]
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.bundle(redisGetReplyFromReader+0x1c) [0x123090b28]
/Users/daniel/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.bundle(hiredis_read+0x184) [0x12308cbe4]
-- Other runtime information -----------------------------------------------
* Loaded script: sidekiq 7.1.5 my-app [0 of 10 busy]
rb_error_frozen_object+0x9c) [0x100e3f96c]
rb_ary_store+0x208) [0x100daacdc]
Hum, that's interesting, that suggest the array we're trying to push into is frozen.
Could be the same bug, but will be just as hard to figure out.
I didn't have a lot of time recently but I can now almost garanti that it's linked to YJIT.
YJIT + 3.2.2 => No problem YJIT + hiredis + {3.2.2, 3.3.0.preview1, 3.2.2-pshopify16} => Random segfaults.
For now, I stopped using hiredis, which is ok for me. But don't hesitate if you have something you want me to test!
Hi there, I recently had a similar crash, in this case it was action-cable. It didn't print out a C level backtrace but here is the error
current-web-1 | corrupted size vs. prev_size
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.rb:106: [BUG] Segmentation fault at 0x0000000000000000
current-web-1 | ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
current-web-1 |
current-web-1 | -- Control frame information -----------------------------------------------
current-web-1 | c:0026 p:---- s:0123 e:000122 CFUNC :flush
current-web-1 | c:0025 p:0009 s:0119 e:000118 METHOD /app/vendor/bundle/ruby/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.rb:106
current-web-1 | c:0024 p:0012 s:0113 e:000112 METHOD /app/vendor/bundle/ruby/3.2.0/gems/redis-client-0.17.0/lib/redis_client.rb:443
current-web-1 | c:0023 p:0007 s:0108 e:000107 BLOCK /app/vendor/bundle/ruby/3.2.0/gems/redis-5.0.7/lib/redis/subscribe.rb:12 [FINISH]
current-web-1 | c:0022 p:---- s:0105 e:000104 CFUNC :synchronize
current-web-1 | c:0021 p:0006 s:0101 e:000100 METHOD /app/vendor/bundle/ruby/3.2.0/gems/redis-5.0.7/lib/redis/subscribe.rb:11
current-web-1 | c:0020 p:0099 s:0096 e:000095 METHOD /app/vendor/bundle/ruby/3.2.0/gems/redis-5.0.7/lib/redis.rb:200
current-web-1 | c:0019 p:0009 s:0088 e:000087 METHOD /app/vendor/bundle/ruby/3.2.0/gems/redis-5.0.7/lib/redis/commands/pubsub.rb:28
current-web-1 | c:0018 p:0008 s:0083 e:000082 BLOCK /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/redis.rb:150
current-web-1 | c:0017 p:0010 s:0080 e:000079 METHOD /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/redis.rb:178
current-web-1 | c:0016 p:0004 s:0075 e:000074 BLOCK /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/redis.rb:150 [FINISH]
current-web-1 | c:0015 p:---- s:0072 e:000071 CFUNC :synchronize
current-web-1 | c:0014 p:0006 s:0068 e:000067 METHOD /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/redis.rb:149
current-web-1 | c:0013 p:0037 s:0063 e:000062 BLOCK /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/subscriber_map.rb:31 [FINISH]
current-web-1 | c:0012 p:---- s:0060 e:000059 CFUNC :synchronize
current-web-1 | c:0011 p:0006 s:0056 e:000055 METHOD /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/subscriber_map.rb:26
current-web-1 | c:0010 p:0009 s:0050 e:000049 METHOD /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/redis.rb:36
current-web-1 | c:0009 p:0015 s:0044 e:000043 METHOD /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/channel_prefix.rb:18
current-web-1 | c:0008 p:0009 s:0038 e:000037 BLOCK /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/connection/internal_channel.rb:27
current-web-1 | c:0007 p:0008 s:0035 e:000034 METHOD /app/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:3
current-web-1 | c:0006 p:0041 s:0027 e:000026 BLOCK /app/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:3 [FINISH]
current-web-1 | c:0005 p:---- s:0021 e:000020 CFUNC :loop
current-web-1 | c:0004 p:0004 s:0017 e:000016 BLOCK /app/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:3 [FINISH]
current-web-1 | c:0003 p:---- s:0014 e:000013 CFUNC :catch
current-web-1 | c:0002 p:0006 s:0009 e:000008 BLOCK /app/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:3 [FINISH]
current-web-1 | c:0001 p:---- s:0003 e:000002 DUMMY [FINISH]
current-web-1 |
current-web-1 | -- Ruby level backtrace information ----------------------------------------
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `block in create_worker'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `catch'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block (2 levels) in create_worker'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `loop'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:343:in `block (3 levels) in create_worker'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `run_task'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/connection/internal_channel.rb:27:in `block (2 levels) in unsubscribe_from_internal_channel'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/channel_prefix.rb:18:in `unsubscribe'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/redis.rb:36:in `unsubscribe'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/subscriber_map.rb:26:in `remove_subscriber'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/subscriber_map.rb:26:in `synchronize'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/subscriber_map.rb:31:in `block in remove_subscriber'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/redis.rb:149:in `remove_channel'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/redis.rb:149:in `synchronize'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/redis.rb:150:in `block in remove_channel'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/redis.rb:178:in `when_connected'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/actioncable-7.0.7.2/lib/action_cable/subscription_adapter/redis.rb:150:in `block (2 levels) in remove_channel'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/redis-5.0.7/lib/redis/commands/pubsub.rb:28:in `unsubscribe'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/redis-5.0.7/lib/redis.rb:200:in `_subscription'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/redis-5.0.7/lib/redis/subscribe.rb:11:in `call_v'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/redis-5.0.7/lib/redis/subscribe.rb:11:in `synchronize'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/redis-5.0.7/lib/redis/subscribe.rb:12:in `block in call_v'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/redis-client-0.17.0/lib/redis_client.rb:443:in `call_v'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.rb:106:in `write'
current-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/hiredis-client-0.17.0/lib/redis_client/hiredis_connection.rb:106:in `flush'
current-web-1 |
current-web-1 | -- Machine register context ------------------------------------------------
current-web-1 | RIP: 0x00007fb814c8e602 RBP: 0x00007fb7fc93bd00 RSP: 0x00007fb7fc93bad0
current-web-1 | RAX: 0x0000000000000000 RBX: 0x00007fb7fca3e700 RCX: 0x00007fb814ca4ce1
current-web-1 | RDX: 0x0000000000000000 RDI: 0x0000000000000002 RSI: 0x00007fb7fc93b9b0
current-web-1 | R8: 0x0000000000000000 R9: 0x00007fb7fc93b9b0 R10: 0x0000000000000008
current-web-1 | R11: 0x0000000000000246 R12: 0x00007fb7fc93bc20 R13: 0x0000000000001000
current-web-1 | R14: 0x0000000000000010 R15: 0x00007fb815712000 EFL: 0x0000000000010246
current-web-1 |
current-web-1 | -- C level backtrace information -------------------------------------------
@mathieumahe I found and fixed a GC issue in https://github.com/redis-rb/redis-client/pull/157, it might be the problem you were witnessing. If you have time I suggest trying the master branch.
Alan also found a second issue when using Timeout.timeout
https://github.com/redis-rb/redis-client/pull/158.
I just re-enable hiredis with the last version of redis-client and hiredis-client. I'll come back in a few days to tell you if I saw a Segfault or not.
Thanks!
I totally forgot to come back. I'm sorry!
Sadly, the same Segfault is still here.
From time to time I have a segfault in the hiredis gem. It seems to happen only on my local computer.
Here's the error :
and then thousand of lines of loaded files.
Here's the
listen_to_changes
function :This code used to work correctly.
I recently update my ruby version to enable YJIT and Jemalloc on my local computer, so it could be related, but the bug is not easily reproducible.
Tell me if you need more information and thanks for your help.