wee_most.py: sigsegv when trying to close DM buffers
Script / WeeChat
- Name of script: weemost.py
- Script version: 0.3.0
- WeeChat version: 3.5
This bug has been reported to the script author? No Response or reason: Registration is currently closed on Sourcehut.
Bug summary
Whenever I try to close the DM buffers, the first couple of them closes with no error. But at a random interval, but always before I can close them all, weechat sigsegv.
Steps to reproduce
1. Connect to a mattermost server 2. Close more than 1 DM buffer
Current behavior
Weechat sigsegv
Expected behavior
Buffer closed
Suggested solutions
N/A
Additional information
I've attached the crash dump. weechat_crash_20240116_37532.log
Error message right after the sigsegv:
*** Very bad! WeeChat is crashing (SIGSEGV received)
*** Full crash dump was saved to /home/phellarv/.local/share/weechat/weechat_crash_20240116_37532.log file.
***
*** Please help WeeChat developers to fix this bug:
***
*** 1. If you have a core file, please run: gdb /path/to/weechat core
*** then issue command: "bt full" and send result to developers.
*** See the user's guide for more info about enabling the core files
*** and reporting crashes:
*** https://weechat.org/doc/stable/user#report_crashes
***
*** 2. Otherwise send the backtrace (below), only if it is a complete trace.
*** Keep the crash log file, just in case developers ask you some info
*** (be careful, private info like passwords may be in this file).
======= WeeChat backtrace =======
(written by WeeChat 3.5, compiled on Mar 31 2022 11:36:01)
001 ??:? [function weechat_backtrace]
002 ??:? [function debug_sigsegv_cb]
003 ??:? [function __sigaction]
004 ??:? [function hashtable_get_item]
005 ??:? [function hashtable_get]
addr2line: '0x1d155': No such file
addr2line: '0x128008': No such file
addr2line: '0xdfadc': No such file
addr2line: '0x7ba1c': No such file
addr2line: '0x1c23af': No such file
addr2line: '0x7863e': No such file
addr2line: '0x1c23af': No such file
addr2line: '0x7863e': No such file
addr2line: '0x1c23af': No such file
addr2line: '0xe2358': No such file
addr2line: '0xe2553': No such file
addr2line: '0xe2ed1': No such file
addr2line: '0xc455': No such file
addr2line: '0x179b5': No such file
020 ??:? [function hook_process_send_buffers]
021 ??:? [function hook_process_timer_cb]
022 ??:? [function hook_signal_send]
023 ??:? [function gui_main_loop]
024 ??:? [function main]
025 ??:? [function __libc_init_first]
026 ??:? [function __libc_start_main]
027 ??:? [function _start]
======= End of backtrace =======
Replied in wee-most-discuss mailing list
I don't use wee-most, but I'm guessing the issue is that it doesn't unset the buffer pointer when a buffer is closed. Most functions in WeeChat that take a buffer pointer don't verify that it's valid (for performance reasons for instance). So it's the plugin/scripts responsibility to not call a function with an invalid pointer. When a buffer is closed, the pointer to it is not valid anymore.
So try adding a buffer closed callback to the buffer creation in ChannelBase, and in that callback do self.buffer = None.