deepfryed/idn-ruby

`IDN::Stringprep.nfkc_normalize("\xE8")` crush on latest development Ruby (Segmentation fault)

ukolovda opened this issue · 6 comments

In stable Ruby 3.0 it give the error:
ArgumentError: NULL pointer given

But in latest version (rvm install ruby-head) it give
Segmentation fault at 0x0000000000000000

How to reproduce:

$ rvm install ruby-head
$ rvm use ruby-head
$ gem install idn-ruby
$ ruby -e 'require "idn"; IDN::Stringprep.nfkc_normalize("\xE8")'

-e:1: [BUG] Segmentation fault at 0x0000000000000000
ruby 3.1.0dev (2021-10-31T09:27:55Z master 13a9597c7c) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0003 p:---- s:0011 e:000010 CFUNC  :nfkc_normalize
c:0002 p:0023 s:0006 e:000005 EVAL   -e:1 [FINISH]
c:0001 p:0000 s:0003 E:0003d0 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
-e:1:in `<main>'
-e:1:in `nfkc_normalize'

-- Machine register context ------------------------------------------------
 RIP: 0x00007fbf88513f35 RBP: 0x0000000000000000 RSP: 0x00007ffd1ae2c598
 RAX: 0x0000000000000000 RBX: 0x0000000055550083 RCX: 0x0000000000000000
 RDX: 0x0000000000000000 RDI: 0x0000000000000000 RSI: 0x00007fbf88812129
  R8: 0x00007fbf8881212b  R9: 0x0000000001bf4530 R10: 0xfffffffffffff10f
 R11: 0x00007fbf88a5e9f0 R12: 0x00007fbf8880fe68 R13: 0x0000000000000001
 R14: 0x00007fbf7ae7ef90 R15: 0x0000000001bf4530 EFL: 0x0000000000010283

-- C level backtrace information -------------------------------------------
/home/ukolovda/.rvm/rubies/ruby-head/lib/libruby.so.3.1(rb_print_backtrace+0x11) [0x7fbf88aed8d5] vm_dump.c:759
/home/ukolovda/.rvm/rubies/ruby-head/lib/libruby.so.3.1(rb_vm_bugreport) vm_dump.c:1045
/home/ukolovda/.rvm/rubies/ruby-head/lib/libruby.so.3.1(rb_bug_for_fatal_signal+0xf0) [0x7fbf888f2cb0] error.c:820
/home/ukolovda/.rvm/rubies/ruby-head/lib/libruby.so.3.1(sigsegv+0x49) [0x7fbf88a439b9] signal.c:964
...

This string used in tests in addressable gem

Hmm... wonder if it makes sense to report the crash to ruby-core? https://bugs.ruby-lang.org/projects/ruby-master/issues

Thank you.
I will write him also.
Please check #10

I'll connect the dots by linking the report you made upstream: https://bugs.ruby-lang.org/issues/18280 (thanks for doing that!)

please help fix this issue stilll learning codes and making sure work is completely secure

fixed in #10