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 on nil string #24

Closed
CodyZeusLiving opened this issue Jan 4, 2019 · 1 comment · Fixed by #25
Closed

Segmentation fault on nil string #24

CodyZeusLiving opened this issue Jan 4, 2019 · 1 comment · Fixed by #25

Comments

@CodyZeusLiving
Copy link

Calling the distance function with a nil argument causes a segmentation fault.

Example stack trace:

-- Ruby level backtrace information ----------------------------------------
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/bin/irb:11:in `<main>'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb.rb:383:in `start'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb.rb:427:in `run'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb.rb:427:in `catch'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb.rb:428:in `block in run'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb.rb:487:in `eval_input'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb/ruby-lex.rb:231:in `each_top_level_statement'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb/ruby-lex.rb:231:in `catch'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb/ruby-lex.rb:232:in `block in each_top_level_statement'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb/ruby-lex.rb:232:in `loop'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb/ruby-lex.rb:246:in `block (2 levels) in each_top_level_statement'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb.rb:488:in `block in eval_input'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb.rb:623:in `signal_status'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb.rb:491:in `block (2 levels) in eval_input'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb/context.rb:380:in `evaluate'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb/workspace.rb:85:in `evaluate'
/Users/codyhunt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/irb/workspace.rb:85:in `eval'
(irb):4:in `irb_binding'
(irb):4:in `distance'

-- Machine register context ------------------------------------------------
 rax: 0x00007fc1a556d280 rbx: 0x0000000000000008 rcx: 0x0000000000000000
 rdx: 0x0000000000000002 rdi: 0x00007ffee9f58db8 rsi: 0x0000000000000008
 rbp: 0x00007ffee9f58da0 rsp: 0x00007ffee9f58d60  r8: 0x0000000000000000
  r9: 0x000000000000000f r10: 0x00007fc1a7248f90 r11: 0x0000000000000002
 r12: 0x0000000000000002 r13: 0x00000001061f5730 r14: 0x00007ffee9f58db8
 r15: 0x000000010606a308 rip: 0x00000001061f513b rfl: 0x0000000000010206

-- C level backtrace information -------------------------------------------
0   libruby.2.5.dylib                   0x0000000105eac497 rb_vm_bugreport + 135
1   libruby.2.5.dylib                   0x0000000105d232b3 rb_bug_context + 467
2   libruby.2.5.dylib                   0x0000000105e198b1 sigsegv + 81
3   libsystem_platform.dylib            0x00007fff7458ab3d _sigtramp + 29
4   jaro_winkler_ext.bundle             0x00000001061f513b codepoints_init + 27
5   jaro_winkler_ext.bundle             0x00000001061f59b5 distance + 197
6   libruby.2.5.dylib                   0x0000000105e9ef84 vm_call_cfunc + 292
7   libruby.2.5.dylib                   0x0000000105e8667e vm_exec_core + 13262
8   libruby.2.5.dylib                   0x0000000105e99620 vm_exec + 144
9   libruby.2.5.dylib                   0x0000000105ea84cd eval_string_with_cref + 1437
10  libruby.2.5.dylib                   0x0000000105e9503a rb_f_eval + 234
11  libruby.2.5.dylib                   0x0000000105e9ef84 vm_call_cfunc + 292
12  libruby.2.5.dylib                   0x0000000105e8667e vm_exec_core + 13262
13  libruby.2.5.dylib                   0x0000000105e99620 vm_exec + 144
14  libruby.2.5.dylib                   0x0000000105ea76ca invoke_block_from_c_bh + 378
15  libruby.2.5.dylib                   0x0000000105ea8803 loop_i + 35
16  libruby.2.5.dylib                   0x0000000105d2d9d7 rb_rescue2 + 311
17  libruby.2.5.dylib                   0x0000000105e9ef84 vm_call_cfunc + 292
18  libruby.2.5.dylib                   0x0000000105e85bc4 vm_exec_core + 10516
19  libruby.2.5.dylib                   0x0000000105e99620 vm_exec + 144
20  libruby.2.5.dylib                   0x0000000105ea76ca invoke_block_from_c_bh + 378
21  libruby.2.5.dylib                   0x0000000105ea879e catch_i + 78
22  libruby.2.5.dylib                   0x0000000105e961ed vm_catch_protect + 173
23  libruby.2.5.dylib                   0x0000000105e969c4 rb_f_catch + 68
24  libruby.2.5.dylib                   0x0000000105e9ef84 vm_call_cfunc + 292
25  libruby.2.5.dylib                   0x0000000105e85bc4 vm_exec_core + 10516
26  libruby.2.5.dylib                   0x0000000105e99620 vm_exec + 144
27  libruby.2.5.dylib                   0x0000000105ea76ca invoke_block_from_c_bh + 378
28  libruby.2.5.dylib                   0x0000000105ea879e catch_i + 78
29  libruby.2.5.dylib                   0x0000000105e961ed vm_catch_protect + 173
30  libruby.2.5.dylib                   0x0000000105e969c4 rb_f_catch + 68
31  libruby.2.5.dylib                   0x0000000105e9ef84 vm_call_cfunc + 292
32  libruby.2.5.dylib                   0x0000000105e85bc4 vm_exec_core + 10516
33  libruby.2.5.dylib                   0x0000000105e99620 vm_exec + 144
34  libruby.2.5.dylib                   0x0000000105d2d311 ruby_exec_internal + 177
35  libruby.2.5.dylib                   0x0000000105d2d208 ruby_run_node + 56
36  ruby                                0x0000000105ca4f2f main + 79

I think this could be fixed by checking for nil arguments and setting them to the empty string instead.

tonytonyjan added a commit that referenced this issue Jan 4, 2019
fix: raises TypeError when input type is not string
@tonytonyjan
Copy link
Owner

@CodyZeusLiving thanks for making the gem better :)

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

Successfully merging a pull request may close this issue.

2 participants