From: "eightbitraptor (Matthew Valentine-House)" Date: 2021-11-01T12:58:04+00:00 Subject: [ruby-core:105886] [Ruby master Bug#18280] Segmentation Fault in rb_utf8_str_new_cstr(NULL) Issue #18280 has been updated by eightbitraptor (Matthew Valentine-House). Compiling with `-fno-delete-null-pointer-checks` prevents this check from being optimised away. Using the test script above and the following compile options ``` set -lx debugflags '-g' set -lx optflags '-Oz -fno-delete-null-pointer-checks' set -lx RUBY_DEVEL 'yes' ./configure --prefix=$HOME/.rbenv/versions/main --disable-install-doc ``` I can disassemble to see this: ``` ��� llvm-objdump --disassemble-symbols=rb_str_new_cstr miniruby miniruby: file format elf64-x86-64 Disassembly of section .text: 000000000017456d : 17456d: 53 pushq %rbx 17456e: 48 89 fb movq %rdi, %rbx 174571: e8 14 00 00 00 callq 0x17458a 174576: 48 89 df movq %rbx, %rdi 174579: e8 f2 70 eb ff callq 0x2b670 17457e: 48 89 df movq %rbx, %rdi 174581: 48 89 c6 movq %rax, %rsi 174584: 5b popq %rbx 174585: e9 09 fe ff ff jmp 0x174393 ``` I believe GCC enables this compile flag by default on most platforms. It doesn't look like clang does it by default. ---------------------------------------- Bug #18280: Segmentation Fault in rb_utf8_str_new_cstr(NULL) https://bugs.ruby-lang.org/issues/18280#change-94427 * Author: ukolovda (Dmitry Ukolov) * Status: Open * Priority: Normal * ruby -v: ruby 3.1.0dev (2021-10-31T09:27:55Z master 13a9597c7c) [x86_64-linux] * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- Ruby process crushed. ` Addressable::URI when parsed from 'http://example.com/%E8' /home/ukolovda/RubymineProjects/external/addressable/lib/addressable/idna/native.rb:34: [BUG] Segmentation fault at 0x0000000000000000 ruby 3.1.0dev (2021-10-31T09:27:55Z master 13a9597c7c) [x86_64-linux] -- Control frame information ----------------------------------------------- c:0043 p:---- s:0231 e:000230 CFUNC :nfkc_normalize c:0042 p:0019 s:0226 e:000225 METHOD /home/ukolovda/RubymineProjects/external/addressable/lib/addressable/idna/native.rb:34 c:0041 p:0323 s:0221 e:000219 METHOD /home/ukolovda/RubymineProjects/external/addressable/lib/addressable/uri.rb:583 c:0040 p:0038 s:0210 e:000209 BLOCK /home/ukolovda/RubymineProjects/external/addressable/lib/addressable/uri.rb:1559 [FINISH] ... -- Machine register context ------------------------------------------------ RIP: 0x00007feea7aa9f35 RBP: 0x0000000000000000 RSP: 0x00007ffc0e4ffdf8 RAX: 0x0000000000000000 RBX: 0x0000000055550083 RCX: 0x0000000000000000 RDX: 0x0000000000000000 RDI: 0x0000000000000000 RSI: 0x0000000004f72d81 R8: 0x0000000004f72d83 R9: 0x00007fee95642a68 R10: 0x0000000000000001 R11: 0x0000000000000000 R12: 0x00007fee96663dc0 R13: 0x0000000000000001 R14: 0x00007fee9a414590 R15: 0x0000000002ce4b20 EFL: 0x0000000000010283 -- C level backtrace information ------------------------------------------- /home/ukolovda/.rvm/rubies/ruby-head/lib/libruby.so.3.1(rb_print_backtrace+0x11) [0x7feea80838d5] 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) [0x7feea7e88cb0] error.c:820 /home/ukolovda/.rvm/rubies/ruby-head/lib/libruby.so.3.1(sigsegv+0x49) [0x7feea7fd99b9] signal.c:964 /lib64/libpthread.so.0(__restore_rt+0x0) [0x7feea7d601b0] /lib64/libc.so.6(__strlen_avx2+0x15) [0x7feea7aa9f35] /home/ukolovda/.rvm/rubies/ruby-head/lib/libruby.so.3.1(rb_str_new_cstr+0x9) [0x7feea7ff4999] string.c:958 /home/ukolovda/.rvm/rubies/ruby-head/lib/libruby.so.3.1(rb_utf8_str_new_cstr+0x7) [0x7feea7ff49f7] string.c:972 /home/ukolovda/.rvm/gems/ruby-head/gems/idn-ruby-0.1.2/lib/idn.so(nfkc_normalize+0x4d) [0x7fee96668a5d] stringprep.c:159 /home/ukolovda/.rvm/rubies/ruby-head/lib/libruby.so.3.1(vm_cfp_consistent_p+0x0) [0x7feea80636a4] vm_insnhelper.c:3025 /home/ukolovda/.rvm/rubies/ruby-head/lib/libruby.so.3.1(vm_call_cfunc_with_frame) vm_insnhelper.c:3027 /home/ukolovda/.rvm/rubies/ruby-head/lib/libruby.so.3.1(vm_sendish+0x4e) [0x7feea80688e9] vm_insnhelper.c:4651 ... ` Lalest ruby version (`rvm install ruby-head`) In previous version it give exception: `ArgumentError: NULL pointer given` -- https://bugs.ruby-lang.org/ Unsubscribe: