-
-
Notifications
You must be signed in to change notification settings - Fork 80
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I was trying to validate that lexing (and parsing) @buildkite's 1000+ .erb files would succeed and found that the process would hang:
Dir.glob("app/views/**/*.erb").each { Herb.lex_file(it) }Iterating on a subset instead, sometimes repeatedly, I was able to get it to crash. I've attached some useful logs below.
I'd be happy to help debug when I get some free time, but I don't think it'll be anytime soon. I suspect you should be able to replicate in the test suite if you enable GC stress mode before a simple lex test.
Ruby: 3.4.4 + YJIT (also crashes if disabled)
Herb: herb gem v0.1.1, libprism v1.4.0, libherb v0.1.1 (Ruby C native extension)
crash log
irb(main):002> require "herb"; 3.times { Dir.glob("app/views/**/*.erb").first(100).each { Herb.lex_file(it); nil } }
(irb):2: [BUG] Segmentation fault at 0x0000008d00140000
ruby 3.4.4 (2025-05-14 revision a38531fd3f) +YJIT +PRISM [arm64-darwin24]
-- 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:0040 p:---- s:0222 e:000221 CFUNC :lex_file
c:0039 p:0006 s:0217 e:000216 BLOCK (irb):2 [FINISH]
c:0038 p:0027 s:0213 e:000212 METHOD <internal:array>:228
c:0037 p:0013 s:0207 e:000206 BLOCK (irb):2
c:0036 p:0024 s:0204 e:000203 METHOD <internal:numeric>:257
c:0035 p:0011 s:0199 e:000198 EVAL (irb):2 [FINISH]
c:0034 p:---- s:0196 e:000195 CFUNC :eval
c:0033 p:0020 s:0188 e:000187 METHOD /Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb/workspace.rb:121
c:0032 p:0090 s:0181 e:000180 METHOD /Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb/context.rb:634
c:0031 p:0049 s:0173 e:000172 METHOD /Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb/context.rb:601
c:0030 p:0030 s:0166 e:000165 BLOCK /Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1049
c:0029 p:0024 s:0162 e:000161 METHOD /Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1380
c:0028 p:0007 s:0156 e:000155 BLOCK /Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1041
c:0027 p:0024 s:0151 e:000150 BLOCK /Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1120
c:0026 p:0017 s:0147 e:000146 METHOD <internal:kernel>:168
c:0025 p:0004 s:0142 e:000141 METHOD /Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1117
c:0024 p:0008 s:0138 e:000137 METHOD /Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1040
c:0023 p:0003 s:0134 e:000133 BLOCK /Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1021 [FINISH]
c:0022 p:---- s:0131 e:000130 CFUNC :catch
c:0021 p:0140 s:0126 E:0018a8 METHOD /Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1020
c:0020 p:0069 s:0115 e:000114 METHOD /Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:904
c:0019 p:0012 s:0109 e:000108 TOP /Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/exe/irb:9 [FINISH]
c:0018 p:---- s:0106 e:000105 CFUNC :load
c:0017 p:0078 s:0101 e:000100 TOP /Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/bin/irb:25 [FINISH]
c:0016 p:---- s:0096 e:000095 CFUNC :load
c:0015 p:0064 s:0091 e:000090 METHOD /Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/cli/exec.rb:59
c:0014 p:0050 s:0085 e:000084 METHOD /Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/cli/exec.rb:23
c:0013 p:0044 s:0080 e:000079 METHOD /Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/cli.rb:452
c:0012 p:0054 s:0073 e:000072 METHOD /Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/vendor/thor/lib/thor/command.rb:28
c:0011 p:0040 s:0065 e:000064 METHOD /Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/vendor/thor/lib/thor/invocation.rb:127
c:0010 p:0213 s:0058 e:000057 METHOD /Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/vendor/thor/lib/thor.rb:538
c:0009 p:0008 s:0045 e:000044 METHOD /Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/cli.rb:35
c:0008 p:0044 s:0040 e:000039 METHOD /Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/vendor/thor/lib/thor/base.rb:584
c:0007 p:0022 s:0033 e:000032 METHOD /Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/cli.rb:29
c:0006 p:0042 s:0028 e:000027 BLOCK /Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/bundler-2.6.7/exe/bundle:28
c:0005 p:0007 s:0022 e:000021 METHOD /Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/friendly_errors.rb:117
c:0004 p:0051 s:0017 E:0026d8 TOP /Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/bundler-2.6.7/exe/bundle:20 [FINISH]
c:0003 p:---- s:0013 e:000012 CFUNC :load
c:0002 p:0081 s:0008 E:001d60 EVAL /Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/bin/bundle:25 [FINISH]
c:0001 p:0000 s:0003 E:0017d0 DUMMY [FINISH]
-- Ruby level backtrace information ----------------------------------------
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/bin/bundle:25:in '<main>'
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/bin/bundle:25:in 'load'
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/bundler-2.6.7/exe/bundle:20:in '<top (required)>'
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/friendly_errors.rb:117:in 'with_friendly_errors'
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/bundler-2.6.7/exe/bundle:28:in 'block in <top (required)>'
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/cli.rb:29:in 'start'
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/vendor/thor/lib/thor/base.rb:584:in 'start'
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/cli.rb:35:in 'dispatch'
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/vendor/thor/lib/thor.rb:538:in 'dispatch'
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in 'invoke_command'
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/vendor/thor/lib/thor/command.rb:28:in 'run'
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/cli.rb:452:in 'exec'
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/cli/exec.rb:23:in 'run'
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/cli/exec.rb:59:in 'kernel_load'
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/ruby/3.4.0/bundler/cli/exec.rb:59:in 'load'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/bin/irb:25:in '<top (required)>'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/bin/irb:25:in 'load'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/exe/irb:9:in '<top (required)>'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:904:in 'start'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1020:in 'run'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1020:in 'catch'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1021:in 'block in run'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1040:in 'eval_input'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1117:in 'each_top_level_statement'
<internal:kernel>:168:in 'loop'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1120:in 'block in each_top_level_statement'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1041:in 'block in eval_input'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1380:in 'signal_status'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb.rb:1049:in 'block (2 levels) in eval_input'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb/context.rb:601:in 'evaluate'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb/context.rb:634:in 'evaluate_expression'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb/workspace.rb:121:in 'evaluate'
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/irb-1.13.2/lib/irb/workspace.rb:121:in 'eval'
(irb):2:in '<compiled>'
<internal:numeric>:257:in 'times'
(irb):2:in 'block in <top (required)>'
<internal:array>:228:in 'each'
(irb):2:in 'block (2 levels) in <top (required)>'
(irb):2:in 'lex_file'
-- Threading information ---------------------------------------------------
Total ractor count: 1
Ruby thread count for this ractor: 1
-- Machine register context ------------------------------------------------
x0: 0x000000012e010400 x1: 0x0000008d00140000 x2: 0x000000011e6b12e0
x3: 0x000000010310b03c x4: 0x0000000000000000 x5: 0x0000000000000000
x6: 0x0000000000000001 x7: 0x0000000000000029 x18: 0x0000000000000000
x19: 0x000000011e739550 x20: 0x0000000000001a3b x21: 0x000000012dfd32e0
x22: 0x000000012e8eaa00 x23: 0x0000000000000000 x24: 0x0000000000000000
x25: 0x0000000000000500 x26: 0x0000000000000000 x27: 0x00006000035ab4f0
x28: 0x000000016d89ffd0 lr: 0x000000010313e234 fp: 0x000000016d89f990
sp: 0x000000016d89f920
-- C level backtrace information -------------------------------------------
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/libruby.3.4.dylib(rb_vm_bugreport+0xb6c) [0x1032a5088]
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/libruby.3.4.dylib(rb_bug_for_fatal_signal+0x100) [0x1030dfaf4]
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/libruby.3.4.dylib(sigsegv+0x84) [0x103205944]
/usr/lib/system/libsystem_platform.dylib(_sigtramp+0x38) [0x19b64c624]
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/libruby.3.4.dylib(rb_iseq_mark_and_move+0x368) [0x10313e234]
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/libruby.3.4.dylib(gc_mark_stacked_objects_incremental+0xac) [0x103106884]
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/libruby.3.4.dylib(gc_continue+0xd0) [0x1031051d8]
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/libruby.3.4.dylib(newobj_cache_miss+0x130) [0x103104e48]
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/libruby.3.4.dylib(newobj_of+0x1bc) [0x1030fb26c]
/Users/joshuayoung/.local/share/mise/installs/ruby/3.4.4/lib/libruby.3.4.dylib(str_enc_new+0x6c) [0x103219c04]
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/herb-0.1.1-arm64-darwin/lib/herb/3.4/herb.bundle(rb_token_from_c_struct+0x110) [0x12a9f7588]
/Users/joshuayoung/Projects/buildkite/buildkite/.bundle/ruby/3.4.0/gems/herb-0.1.1-arm64-darwin/lib/herb/3.4/herb.bundle(create_lex_result+0x88) [0x12a9f7678]
-- Other runtime information -----------------------------------------------
* Process memory map:
!! I've ommitted this to fit into the PR body character limit, happy to provide if needed. !!
[IMPORTANT]
Don't forget to include the Crash Report log file under
DiagnosticReports directory in bug reports.
[1] 22283 segmentation fault bundle exec irb
lldb backtrace on hang
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
* frame #0: 0x00000001017fcfd0 libruby.3.4.dylib`gc_sweep_plane + 112
frame #1: 0x00000001017fce44 libruby.3.4.dylib`gc_sweep_page + 176
frame #2: 0x00000001017fb510 libruby.3.4.dylib`gc_sweep_step + 292
frame #3: 0x00000001017f93a8 libruby.3.4.dylib`gc_continue + 672
frame #4: 0x00000001017f8e0c libruby.3.4.dylib`newobj_cache_miss + 244
frame #5: 0x00000001017ef26c libruby.3.4.dylib`newobj_of + 444
frame #6: 0x0000000101864678 libruby.3.4.dylib`rb_class_allocate_instance + 68
frame #7: 0x000000010186b858 libruby.3.4.dylib`class_call_alloc_func + 36
frame #8: 0x0000000101865fe0 libruby.3.4.dylib`rb_class_new_instance + 60
frame #9: 0x000000013cab7364 herb.bundle`rb_location_from_c_struct + 408
frame #10: 0x000000013cab7578 herb.bundle`rb_token_from_c_struct + 256
frame #11: 0x000000013cab7678 herb.bundle`create_lex_result + 136
frame #12: 0x000000011cf28460
frame #13: 0x000000010196d17c libruby.3.4.dylib`rb_vm_exec + 424
frame #14: 0x000000010196d7e0 libruby.3.4.dylib`rb_vm_invokeblock + 256
frame #15: 0x000000011c6dcc1c
frame #16: 0x0000000101972df4 libruby.3.4.dylib`vm_exec_core + 18700
frame #17: 0x000000010196d190 libruby.3.4.dylib`rb_vm_exec + 444
frame #18: 0x000000010196d7e0 libruby.3.4.dylib`rb_vm_invokeblock + 256
frame #19: 0x000000011cf28334
frame #20: 0x0000000101972df4 libruby.3.4.dylib`vm_exec_core + 18700
frame #21: 0x000000010196d34c libruby.3.4.dylib`rb_vm_exec + 888
frame #22: 0x000000010197beb8 libruby.3.4.dylib`rb_f_eval + 472
frame #23: 0x000000010189b964 libruby.3.4.dylib`bind_eval + 144
frame #24: 0x000000010198ad8c libruby.3.4.dylib`vm_call_cfunc_with_frame_ + 240
frame #25: 0x0000000101972ce8 libruby.3.4.dylib`vm_exec_core + 18432
frame #26: 0x000000010196d190 libruby.3.4.dylib`rb_vm_exec + 444
frame #27: 0x0000000101992c04 libruby.3.4.dylib`invoke_block_from_c_bh + 876
frame #28: 0x0000000101992334 libruby.3.4.dylib`catch_i + 108
frame #29: 0x000000010197d17c libruby.3.4.dylib`vm_catch_protect + 188
frame #30: 0x000000010197db6c libruby.3.4.dylib`rb_f_catch + 112
frame #31: 0x000000010198ad8c libruby.3.4.dylib`vm_call_cfunc_with_frame_ + 240
frame #32: 0x0000000101970bc0 libruby.3.4.dylib`vm_exec_core + 9944
frame #33: 0x000000010196d190 libruby.3.4.dylib`rb_vm_exec + 444
frame #34: 0x0000000101992c04 libruby.3.4.dylib`invoke_block_from_c_bh + 876
frame #35: 0x0000000101992334 libruby.3.4.dylib`catch_i + 108
frame #36: 0x000000010197d17c libruby.3.4.dylib`vm_catch_protect + 188
frame #37: 0x000000010197db6c libruby.3.4.dylib`rb_f_catch + 112
frame #38: 0x000000010198ad8c libruby.3.4.dylib`vm_call_cfunc_with_frame_ + 240
frame #39: 0x0000000101970bc0 libruby.3.4.dylib`vm_exec_core + 9944
frame #40: 0x000000010196d1bc libruby.3.4.dylib`rb_vm_exec + 488
frame #41: 0x000000010196d7e0 libruby.3.4.dylib`rb_vm_invokeblock + 256
frame #42: 0x000000011cce0aac
frame #43: 0x0000000101972df4 libruby.3.4.dylib`vm_exec_core + 18700
frame #44: 0x000000010196d34c libruby.3.4.dylib`rb_vm_exec + 888
frame #45: 0x000000010183f7fc libruby.3.4.dylib`load_iseq_eval + 548
frame #46: 0x000000010183da5c libruby.3.4.dylib`require_internal + 1212
frame #47: 0x000000010183ced8 libruby.3.4.dylib`rb_require_string_internal + 88
frame #48: 0x000000010183cda8 libruby.3.4.dylib`rb_f_require + 68
frame #49: 0x000000011c87836c
frame #50: 0x0000000101972df4 libruby.3.4.dylib`vm_exec_core + 18700
frame #51: 0x000000010196d34c libruby.3.4.dylib`rb_vm_exec + 888
frame #52: 0x000000010183f7fc libruby.3.4.dylib`load_iseq_eval + 548
frame #53: 0x000000010183cb64 libruby.3.4.dylib`rb_load_internal + 132
frame #54: 0x000000010183e778 libruby.3.4.dylib`rb_f_load + 140
frame #55: 0x000000010198ad8c libruby.3.4.dylib`vm_call_cfunc_with_frame_ + 240
frame #56: 0x0000000101972ce8 libruby.3.4.dylib`vm_exec_core + 18432
frame #57: 0x000000010196d34c libruby.3.4.dylib`rb_vm_exec + 888
frame #58: 0x000000010183f7fc libruby.3.4.dylib`load_iseq_eval + 548
frame #59: 0x000000010183cb64 libruby.3.4.dylib`rb_load_internal + 132
frame #60: 0x000000010183e778 libruby.3.4.dylib`rb_f_load + 140
frame #61: 0x000000010198ad8c libruby.3.4.dylib`vm_call_cfunc_with_frame_ + 240
frame #62: 0x0000000101972ce8 libruby.3.4.dylib`vm_exec_core + 18432
frame #63: 0x000000010196d190 libruby.3.4.dylib`rb_vm_exec + 444
frame #64: 0x00000001017deb30 libruby.3.4.dylib`rb_ec_exec_node + 140
frame #65: 0x00000001017dea58 libruby.3.4.dylib`ruby_run_node + 64
frame #66: 0x0000000100c68628 ruby`main + 104
frame #67: 0x000000019b272b98 dyld`start + 6076
(lldb)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working