weechat icon indicating copy to clipboard operation
weechat copied to clipboard

Quakenet challengeauth.rb plugin crashes Weechat with Ruby 3

Open Hackerpcs opened this issue 5 years ago • 6 comments

Since Ruby was updated to 3, Quakenet challengeauth.rb plugin https://weechat.org/scripts/source/challengeauth.rb.html/ crashes Weechat. I've downgraded to Ruby 2.7.2 and but then the plugin doesn't work

Unable to load plugin "/usr/lib/weechat/plugins/ruby.so": libruby.so.3.0: cannot open shared object file: No such file or directory

  • WeeChat version: 3.1 [compiled on Mar 19 2021 22:07:12]
  • OS, distribution and version: Arch Linux, updated
  • Terminal: zsh
  • Terminal multiplexer: tmux

Hackerpcs avatar Apr 15 '21 07:04 Hackerpcs

Hi @Hackerpcs,

Could you please provide a complete backtrace of the crash? For more info, see: https://weechat.org/files/doc/devel/weechat_user.en.html#report_crashes

flashcode avatar Apr 15 '21 13:04 flashcode

https://gist.githubusercontent.com/Hackerpcs/9cb4b9afb047343cfa8cc9ffa4c04f2c/raw/646ee5291015213008435b2434dc43693bcb601c/gistfile1.txt

Hackerpcs avatar Apr 16 '21 08:04 Hackerpcs

@Hackerpcs, could you please get a backtrace with gdb? The WeeChat crash log file doesn't provide accurate information on the exact location in code where the crash happened. Thanks.

flashcode avatar Apr 17 '21 06:04 flashcode

gdb ~/weechat_debug/bin/weechat /home/irc/core.weechat.1004.a9ac7491d8da4804946464c24349a723.317257.1618653734000000
GNU gdb (GDB) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/irc/weechat_debug/bin/weechat...
[New LWP 317257]
Warning: couldn't activate thread debugging using libthread_db: Cannot find new threads: generic error

warning: File "/usr/lib/libthread_db-1.0.so" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
        add-auto-load-safe-path /usr/lib/libthread_db-1.0.so
line to your configuration file "/home/irc/.gdbinit".
To completely disable this security protection add
        set auto-load safe-path /
line to your configuration file "/home/irc/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
        info "(gdb)Auto-loading safe path"

warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Core was generated by `/home/irc/weechat_debug/bin/weechat'.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007f1a28fa5ef5 in raise () from /usr/lib/libc.so.6
(gdb) bt full
#0  0x00007f1a28fa5ef5 in raise () from /usr/lib/libc.so.6
No symbol table info available.
#1  0x00007f1a28f8f862 in abort () from /usr/lib/libc.so.6
No symbol table info available.
#2  0x0000559193b8b174 in weechat_shutdown (return_code=1, crash=1) at /home/irc/compile/weechat-3.1/src/core/weechat.c:752
No locals.
#3  0x0000559193bb5556 in debug_sigsegv () at /home/irc/compile/weechat-3.1/src/core/wee-debug.c:184
No locals.
#4  0x00007f1a2742e8a8 in ?? () from /usr/lib/libruby.so.3.0
No symbol table info available.
#5  0x00007f1a2754fdaa in ?? () from /usr/lib/libruby.so.3.0
No symbol table info available.
#6  <signal handler called>
No symbol table info available.
#7  0x00007f1a27433169 in ?? () from /usr/lib/libruby.so.3.0
No symbol table info available.
#8  0x00007f1a2743889a in ?? () from /usr/lib/libruby.so.3.0
No symbol table info available.
#9  0x00007f1a274389fc in rb_exc_raise () from /usr/lib/libruby.so.3.0
No symbol table info available.
#10 0x00007f1a2742fd55 in ?? () from /usr/lib/libruby.so.3.0
No symbol table info available.
#11 0x00007f1a2742fdf4 in rb_raise () from /usr/lib/libruby.so.3.0
No symbol table info available.
#12 0x00007f1a274cdd80 in ?? () from /usr/lib/libruby.so.3.0
No symbol table info available.
#13 0x00007f1a274cf0a7 in rb_convert_type_with_id () from /usr/lib/libruby.so.3.0
No symbol table info available.
#14 0x00007f1a2756b348 in rb_string_value () from /usr/lib/libruby.so.3.0
No symbol table info available.
#15 0x00007f1a2756ebe8 in rb_string_value_ptr () from /usr/lib/libruby.so.3.0
No symbol table info available.
#16 0x00007f1a2770f255 in weechat_ruby_print_exception (err=94083766918120) at /home/irc/compile/weechat-3.1/src/plugins/ruby/weechat-ruby.c:285
        backtrace = 94083766917760
        tmp1 = 94083766916800
        tmp2 = 8
        tmp3 = 0
        i = 21905
        ruby_error = 6
        line = 0x559195819be8 "\001"
        cline = 0x0
        err_msg = 0x55919580b640 "undefined method `~' for 2048:Integer"
        err_class = 0x7f1a2774320e "@load_eval_file_error"
#17 0x00007f1a27710366 in weechat_ruby_load (filename=0x7fff325cc360 "/home/irc/.weechat/ruby/autoload/challengeauth.rb", code=0x0) at /home/irc/compile/weechat-3.1/src/plugins/ruby/weechat-ruby.c:670
        modname = "WeechatRubyModule0\000\000\000\000\000\000\304\033i`\000\000\000\000\b\227u\b\000\000\000\000\263y_]", '\000' <repeats 12 times>, "\201>y`\000\000\000"
        ruby_retcode = 5
        err = 2050
        argv = {94083765966840, 94083765966800}
        ruby_error = 0
        buf = {st_dev = 39, st_ino = 19085956, st_nlink = 1, st_mode = 33208, st_uid = 1004, st_gid = 1005, __pad0 = 0, st_rdev = 0, st_size = 3736, st_blksize = 4096, st_blocks = 8, st_atim = {tv_sec = 1617501124,
            tv_nsec = 141924104}, st_mtim = {tv_sec = 1566538163, tv_nsec = 0}, st_ctim = {tv_sec = 1618648770, tv_nsec = 590976001}, __glibc_reserved = {0, 0, 0}}
#18 0x00007f1a27710617 in weechat_ruby_load_cb (data=0x0, filename=0x7fff325cc360 "/home/irc/.weechat/ruby/autoload/challengeauth.rb") at /home/irc/compile/weechat-3.1/src/plugins/ruby/weechat-ruby.c:740
No locals.
#19 0x0000559193bd722b in util_exec_on_files (directory=0x559195694020 "/home/irc/.weechat/ruby/autoload", recurse_subdirs=0, hidden_files=0, callback=0x7f1a277105f6 <weechat_ruby_load_cb>, callback_data=0x0)
    at /home/irc/compile/weechat-3.1/src/core/wee-util.c:748
        complete_filename = "/home/irc/.weechat/ruby/autoload/challengeauth.rb\000\\2\377\177\000\000\020\002\000\000\000\000\000\000\016\000\000\000\000\000\000\000\320\312\\2\377\177", '\000' <repeats 42 times>, "\001\000\000\000\000\0
00\000\000\\\000\000\000w\000\000\000n\000\000\000|\000\000\000pAi\225\221U\000\000 \000\000\000\000\000\000\000\020\002\000\000\000\000\000\000(\350h\225\221U\000\000\006\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000@\304\
\2\377\177\000\000"...
        dir = 0x5591956be860
        entry = 0x5591956be8c0
        statbuf = {st_dev = 39, st_ino = 19086061, st_nlink = 1, st_mode = 41471, st_uid = 1004, st_gid = 1005, __pad0 = 0, st_rdev = 0, st_size = 19, st_blksize = 4096, st_blocks = 8, st_atim = {tv_sec = 1617501124,
            tv_nsec = 171923767}, st_mtim = {tv_sec = 1566538163, tv_nsec = 0}, st_ctim = {tv_sec = 1618558593, tv_nsec = 591477641}, __glibc_reserved = {0, 0, 0}}
#20 0x00007f1a27fa57ce in plugin_script_auto_load (weechat_plugin=0x559194f075a0, callback=0x7f1a277105f6 <weechat_ruby_load_cb>) at /home/irc/compile/weechat-3.1/src/plugins/plugin-script.c:481
        dir_home = 0x559195694000 "/home/irc/.weechat"
        dir_name = 0x559195694020 "/home/irc/.weechat/ruby/autoload"
        dir_length = 38
--Type <RET> for more, q to quit, c to continue without paging--
#21 0x00007f1a27fa5278 in plugin_script_init (weechat_plugin=0x559194f075a0, argc=0, argv=0x0, plugin_data=0x7f1a2774c580 <ruby_data>) at /home/irc/compile/weechat-3.1/src/plugins/plugin-script.c:294
        string = "ruby_version\000ter\000oad\000\000\000\000\a\000\000\000\000\000\000\000 \000\000\000\000\000\000\000\030\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000@", '\000' <repeats 15
 times>, "\002\000\000\000\060\000\000\000\002", '\000' <repeats 23 times>, "\005\000\000\000\000\000\000\000n\000\000\000|\000\000\000hXp'\032\177\000\000\220\071i\225\221U\000\000\270bo'\032\177\000\000؟2&\032\177\000\000Hpz\225\221U\0
00\000\313}\000\000\000\000\000\000\000\032s\225\221U\000\000͵G'\032\177\000\000\360\324\\2\377\177\000\000*\205"...
        completion = 0x5591955e83e0 "\017"
        action_signals = {0x7f1a27faf0d2 "install", 0x7f1a27faf0da "remove", 0x7f1a27faf0e1 "autoload", 0x0}
        i = 0
        auto_load_scripts = 1
#22 0x00007f1a27711d76 in weechat_plugin_init (plugin=0x559194f075a0, argc=0, argv=0x0) at /home/irc/compile/weechat-3.1/src/plugins/ruby/weechat-ruby.c:1409
        ruby_error = 0
        err = 844945072
        weechat_ruby_code = 0x7f1a277434e0 "$stdout = WeechatOutputs\n$stderr = WeechatOutputs\nbegin  if RUBY_VERSION.split('.')[0] == '1' and RUBY_VERSION.split('.')[1] <= '8'\n    require 'rubygems'\n  else\n    require 'thread'\n
class ::Mutex"...
        variable_in_this_stack_frame = 6774016206
#23 0x0000559193c3498a in plugin_call_init (plugin=0x559194f075a0, argc=1, argv=0x7fff325cd918) at /home/irc/compile/weechat-3.1/src/plugins/plugin.c:361
        init_func = 0x7f1a277119ad <weechat_plugin_init>
        plugin_argc = 0
        no_connect = 0
        rc = 0
        old_auto_connect = 1
        plugin_argv = 0x0
#24 0x0000559193c36c3c in plugin_auto_load (force_plugin_autoload=0x0, load_from_plugin_path=1, load_from_extra_lib_dir=1, load_from_lib_dir=1, argc=1, argv=0x7fff325cd918) at /home/irc/compile/weechat-3.1/src/plugins/plugin.c:1117
        dir_name = 0x559194eef210 ""
        plugin_path = 0x559194ee2940 "Alias commands"
        plugin_path2 = 0x559194ee1740 "FIFO pipe for remote control"
        extra_libdir = 0x0
        ptr_plugin_autoload = 0x559194b678d0 "*,!xfer"
        ptr_plugin = 0x559194f075a0
        plugin_args = {argc = 1, argv = 0x7fff325cd918}
        arraylist = 0x559194eef250
        length = 52
        i = 12
#25 0x0000559193c37397 in plugin_init (force_plugin_autoload=0x0, argc=1, argv=0x7fff325cd918) at /home/irc/compile/weechat-3.1/src/plugins/plugin.c:1382
No locals.
#26 0x0000559193b8b42a in weechat_init (argc=1, argv=0x7fff325cd918, gui_init_cb=0x559193c2dda0 <gui_main_init>) at /home/irc/compile/weechat-3.1/src/core/weechat.c:835
No locals.
#27 0x0000559193b89f3a in main (argc=1, argv=0x7fff325cd918) at /home/irc/compile/weechat-3.1/src/gui/curses/normal/main.c:42
No locals.
(gdb)

Hackerpcs avatar Apr 17 '21 10:04 Hackerpcs

Hi,

Thanks I can reproduce the issue on Archlinux with Ruby 3.0.1.

For now, Ruby 3 is not supported in WeeChat and has not been tested at all, so I would suggest to use only Ruby 2.x for now. Ruby 3 should not be detected, but due to a fallback on ruby, Ruby 3.0 can be compiled and used (which is another issue).

I'll try to fix this crash and check if other scripts are working well with Ruby 3, in which case I'll add official support of Ruby 3.

flashcode avatar Apr 17 '21 10:04 flashcode

Having a similar issue with substution.rb, same ruby version (3.1.0) -- using opensuse tumbleweed which appears to have switched

A-UNDERSCORE-D avatar Feb 17 '22 10:02 A-UNDERSCORE-D

I fixed the problem, but the display of exception class name is not the best we could do:

ruby: unable to run function "script_ruby_eval"
ruby: error: (eval):1:in `puts': no implicit conversion of Integer into String (#<Class:#<TypeError:0x00007fb4e4101698>>)
ruby: error:      from (eval):1:in `puts'
ruby: error:      from (eval):1:in `script_ruby_eval'
ruby: error:      from (eval):7:in `module_eval'
ruby: error:      from (eval):7:in `script_ruby_eval'

While it was like this with Ruby 2:

ruby: unable to run function "script_ruby_eval"
ruby: error: (eval):1:in `puts': no implicit conversion of Integer into String (TypeError)
ruby: error:      from (eval):1:in `puts'
ruby: error:      from (eval):1:in `script_ruby_eval'
ruby: error:      from (eval):7:in `module_eval'
ruby: error:      from (eval):7:in `script_ruby_eval'

Any help is appreciated to fix this class name, though it's not mandatory, the most important thing is that it no longer crashes.

flashcode avatar May 31 '23 19:05 flashcode