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

script unloading hangs with 100% CPU #406

Closed
lorenzhs opened this Issue Apr 20, 2015 · 11 comments

Comments

Projects
None yet
4 participants
@lorenzhs
Copy link

lorenzhs commented Apr 20, 2015

I wanted to upgrade from weechat-devel_1.2-1dev20150324 to weechat-devel_1.2-1dev20150420 from the officially unofficial dev builds. I'm using @torhve's matrix script (https://github.com/torhve/weechat-matrix-protocol-script), which I wanted to unload before /upgrade with /script unload matrix, since it is not possible to upgrade while it is running ("Can't upgrade: there is one or more background process (hook type 'process' or 'connect')"). However, the /script unload matrix command hangs:

I downgraded the packages and attached gdb, backtrace follows. For a version with syntax highlighting, refer to https://paste.kde.org/prlfiegl8/z5jjqc.

(gdb) bt
#0  plugin_script_remove (weechat_plugin=0x2bd45b0, scripts=0x7f6269d74548, last_script=0x7f6269d74540, script=0x2d543d0) at /home/flashcode/build/debian/weechat/src/plugins/plugin-script.c:789
#1  0x00007f6269b4c681 in weechat_lua_unload (script=0x2d543d0) at /home/flashcode/build/debian/weechat/src/plugins/lua/weechat-lua.c:514
#2  0x00007f6269b4ce08 in weechat_lua_unload_name (name=0x34d4e20 "matrix") at /home/flashcode/build/debian/weechat/src/plugins/lua/weechat-lua.c:540
#3  0x00007f6269b4d32d in weechat_lua_command_cb (data=<optimized out>, buffer=<optimized out>, argc=<optimized out>, argv=0x40ece90, argv_eol=<optimized out>) at /home/flashcode/build/debian/weechat/src/plugins/lua/weechat-lua.c:694
#4  0x000000000044c34a in hook_command_exec (buffer=buffer@entry=0x22f3500, any_plugin=any_plugin@entry=1, plugin=plugin@entry=0x0, string=string@entry=0x4ac8f10 "/lua unload matrix")
    at /home/flashcode/build/debian/weechat/src/core/wee-hook.c:803
#5  0x0000000000452c7f in input_exec_command (buffer=buffer@entry=0x22f3500, any_plugin=any_plugin@entry=1, plugin=0x0, string=string@entry=0x3cef9f0 "/lua unload matrix") at /home/flashcode/build/debian/weechat/src/core/wee-input.c:107
#6  0x00000000004530e4 in input_data (buffer=buffer@entry=0x22f3500, data=data@entry=0x3c27a80 "/lua unload matrix") at /home/flashcode/build/debian/weechat/src/core/wee-input.c:270
#7  0x000000000049c63f in plugin_api_command (plugin=<optimized out>, buffer=0x22f3500, command=0x7fffe9ace9f0 "/lua unload matrix") at /home/flashcode/build/debian/weechat/src/plugins/plugin-api.c:276
#8  0x00007f626b21cbcc in script_action_unload (name=<optimized out>, quiet=0) at /home/flashcode/build/debian/weechat/src/plugins/script/script-action.c:287
#9  0x00007f626b21e094 in script_action_run () at /home/flashcode/build/debian/weechat/src/plugins/script/script-action.c:1220
#10 0x00007f626b220f9f in script_command_action (buffer=buffer@entry=0x22f3500, action=0x408ff40 "unload", arguments=0x4b73010 "matrix", need_repository=need_repository@entry=0)
    at /home/flashcode/build/debian/weechat/src/plugins/script/script-command.c:84
#11 0x00007f626b2212b3 in script_command_script (data=<optimized out>, buffer=0x22f3500, argc=3, argv=0x497f750, argv_eol=0x45f8f30) at /home/flashcode/build/debian/weechat/src/plugins/script/script-command.c:177
#12 0x000000000044c34a in hook_command_exec (buffer=buffer@entry=0x22f3500, any_plugin=any_plugin@entry=1, plugin=plugin@entry=0x0, string=string@entry=0x3c42c60 "/script unload matrix")
    at /home/flashcode/build/debian/weechat/src/core/wee-hook.c:803
#13 0x0000000000452c7f in input_exec_command (buffer=buffer@entry=0x22f3500, any_plugin=any_plugin@entry=1, plugin=0x0, string=string@entry=0x4811ce0 "/script unload matrix")
    at /home/flashcode/build/debian/weechat/src/core/wee-input.c:107
#14 0x00000000004530e4 in input_data (buffer=buffer@entry=0x22f3500, data=data@entry=0x42e1b70 "/script unload matrix") at /home/flashcode/build/debian/weechat/src/core/wee-input.c:270
#15 0x000000000049c63f in plugin_api_command (plugin=<optimized out>, buffer=0x22f3500, command=0x244d800 "/script unload matrix") at /home/flashcode/build/debian/weechat/src/plugins/plugin-api.c:276
#16 0x00007f626b440fe1 in relay_weechat_protocol_input_timer_cb (data=0x2234b10, remaining_calls=<optimized out>) at /home/flashcode/build/debian/weechat/src/plugins/relay/weechat/relay-weechat-protocol.c:381
#17 0x000000000044feaf in hook_timer_exec () at /home/flashcode/build/debian/weechat/src/core/wee-hook.c:1173
#18 0x00000000004664d8 in gui_main_loop () at /home/flashcode/build/debian/weechat/src/gui/curses/gui-curses-main.c:390
#19 0x0000000000426bb5 in main (argc=<optimized out>, argv=<optimized out>) at /home/flashcode/build/debian/weechat/src/gui/curses/main.c:41
(gdb) bt full
#0  plugin_script_remove (weechat_plugin=0x2bd45b0, scripts=0x7f6269d74548, last_script=0x7f6269d74540, script=0x2d543d0) at /home/flashcode/build/debian/weechat/src/plugins/plugin-script.c:789
        ptr_script_cb = <optimized out>
        ptr_script_cb2 = 0x3db6de0
#1  0x00007f6269b4c681 in weechat_lua_unload (script=0x2d543d0) at /home/flashcode/build/debian/weechat/src/plugins/lua/weechat-lua.c:514
        rc = <optimized out>
        interpreter = 0x2d45790
        filename = 0x4b22ed0 "/home/weechat/.weechat/lua/autoload/matrix.lua"
#2  0x00007f6269b4ce08 in weechat_lua_unload_name (name=0x34d4e20 "matrix") at /home/flashcode/build/debian/weechat/src/plugins/lua/weechat-lua.c:540
        ptr_script = <optimized out>
#3  0x00007f6269b4d32d in weechat_lua_command_cb (data=<optimized out>, buffer=<optimized out>, argc=<optimized out>, argv=0x40ece90, argv_eol=<optimized out>) at /home/flashcode/build/debian/weechat/src/plugins/lua/weechat-lua.c:694
        ptr_name = 0x34d4e20 "matrix"
        path_script = <optimized out>
#4  0x000000000044c34a in hook_command_exec (buffer=buffer@entry=0x22f3500, any_plugin=any_plugin@entry=1, plugin=plugin@entry=0x0, string=string@entry=0x4ac8f10 "/lua unload matrix")
    at /home/flashcode/build/debian/weechat/src/core/wee-hook.c:803
        ptr_hook = <optimized out>
        next_hook = 0x0
        hook_plugin = 0x0
        hook_other_plugin = 0x2b72250
        hook_other_plugin2 = 0x0
        hook_incomplete_command = 0x0
        argv = 0x40ece90
        argv_eol = 0x498fa40
        ptr_command_name = <optimized out>
        argc = 3
        rc = -1
        length_command_name = 3
        allow_incomplete_commands = 0
        count_other_plugin = 1
        count_incomplete_commands = 0
#5  0x0000000000452c7f in input_exec_command (buffer=buffer@entry=0x22f3500, any_plugin=any_plugin@entry=1, plugin=0x0, string=string@entry=0x3cef9f0 "/lua unload matrix") at /home/flashcode/build/debian/weechat/src/core/wee-input.c:107
        command = 0x4ac8f10 "/lua unload matrix"
        command_name = 0x432e980 "/lua"
        pos = <optimized out>
        rc = 0
#6  0x00000000004530e4 in input_data (buffer=buffer@entry=0x22f3500, data=data@entry=0x3c27a80 "/lua unload matrix") at /home/flashcode/build/debian/weechat/src/core/wee-input.c:270
        pos = 0x0
        buf = <optimized out>
        str_buffer = "0x22f3500\000\000\000\000\000\000\000n\000\000\000w", '\000' <repeats 11 times>, "|\000\000\000\377\177\000\000\060\000\000\000\060\000\000\000P\351\254\351\377\177\000\000 \026\345ob\177\000\000\023", '\000' <repeats 15 times>"\320, C\325\002\000\000\000\000\001", '\000' <repeats 15 times>, "p\240\262ob\177\000\000\000\000\000\000\000\212\266@\360\351\254\351\377\177\000"
        new_data = 0x3cef9f0 "/lua unload matrix"
        buffer_full_name = 0x3ff10a0 "core.weechat"
        ptr_data = 0x3cef9f0 "/lua unload matrix"
        ptr_data_for_buffer = 0x0
        length = <optimized out>
        char_size = <optimized out>
        first_command = <optimized out>
        rc = <optimized out>
#7  0x000000000049c63f in plugin_api_command (plugin=<optimized out>, buffer=0x22f3500, command=0x7fffe9ace9f0 "/lua unload matrix") at /home/flashcode/build/debian/weechat/src/plugins/plugin-api.c:276
        command2 = 0x3c27a80 "/lua unload matrix"
        rc = <optimized out>
#8  0x00007f626b21cbcc in script_action_unload (name=<optimized out>, quiet=0) at /home/flashcode/build/debian/weechat/src/plugins/script/script-action.c:287
        pos = <optimized out>
        hdata_name = "lua_script\000t\000\177\000\000\000\000\000\000\001\000\000\000\027\000\000\000\000\000\000\000y\363lkb\177\000\000\030\000\000\000\060\000\000\000@\360\254\351\377\177\000\000\200\357\254\351\377\177\000\000\220\350\254\351\377\177\000\000\001\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\003\000\000\000f", '\000' <repeats 11 times>, "(\000\000\000\060\000\000\000\220\360\254\351\377\177\000\000\320\357\254\351\377\177\000"
        filename = <optimized out>
        ptr_base_name = <optimized out>
        str_command = "/lua unload matrix\000\351\377\177\000\000w\362\254\351\377\177\000\000\000\000\000\000\000\000\000\000\311\177\257ob\177\000\000\020\353\254\351\377\177\000\000\001\000\000\000\000\000\000\000\001", '\000' <repeats 15 times>"\200, \360\254\351\377\177\000\000\340\202\301ob\177\000\000\000\000\000\000\000\000\000\000p\223\261ob\177\000\000P\353\254\351\377\177\000\000\301)\257ob\177\000\000\200\360\254\351\377\177\000\000p\360\254\351\377\177\000\000\217\312K\000\000\000\000\000\230\312K", '\000' <repeats 13 times>"\311, \177\257ob\177\000\000\000\000\000\000\377\177\000\000\372\231\257ob\177\000\000\000\354\254\351\377\177\000\000\000\000\000\000\000\000\000\000 955\377\177\000\000\000\000\000\000b\177\000\000\t\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000 \361\254\351\377\177\000\000\360\202\301ob\177\000\000\000\000\000\000\000\000\000\000p\223\261ob"...
        ptr_filename = <optimized out>
        ptr_registered_name = <optimized out>
        language = <optimized out>
        found = <optimized out>
        hdata = <optimized out>
        ptr_script = <optimized out>
#9  0x00007f626b21e094 in script_action_run () at /home/flashcode/build/debian/weechat/src/plugins/script/script-action.c:1220
        actions = 0x498db70
        argv = 0x49a9d60
        argv_eol = 0x44f4740
        num_actions = 1
        argc = 2
        i = 0
        quiet = 0
#10 0x00007f626b220f9f in script_command_action (buffer=buffer@entry=0x22f3500, action=0x408ff40 "unload", arguments=0x4b73010 "matrix", need_repository=need_repository@entry=0)
    at /home/flashcode/build/debian/weechat/src/plugins/script/script-command.c:84
        ptr_script = <optimized out>
        str_action = "unload matrix\000\000\000\377\377\377\377\377\377\377\377", '\000' <repeats 12 times>, "b\177\000\000`\004\345ob\177\000\000\002\000\000\000\000\000\000\000@", '\000' <repeats 15 times>, "0", '\000' <repeats 15 times>, "[", '\000' <repeats 23 times>, "n\000\000\000w", '\000' <repeats 11 times>, "|\000\000\000\000\000\000\000\215\004F\000\000\000\000\000g\000\000\000\000\000\000\000>\004F", '\000' <repeats 13 times>"\215, \004F\000\000\000\000\000h\000\000\000\000\000\000\000pc\230\004\000\000\000\000\067\bF\000\000\000\000\000pc\230\004\000\000\000\000\240\212\376\002\000\000\000\000w\233\257\004\000\000\000\000\a\000\000\000\000\000\000\000\240\212\376\002", '\000' <repeats 12 times>"\240, \212\376\002\000\000\000\000"...
        value = <optimized out>
        error = 0x4b73010 "matrix"
        quiet = 0
#11 0x00007f626b2212b3 in script_command_script (data=<optimized out>, buffer=0x22f3500, argc=3, argv=0x497f750, argv_eol=0x45f8f30) at /home/flashcode/build/debian/weechat/src/plugins/script/script-command.c:177
        error = <optimized out>
        command = "\003\000\000\000\000\000\000\000\234uK\000\000\000\000\000\003\000\000\000\000\000\000\000H\217_\004\000\000\000\000\003\000\000\000\000\000\000\000\345Tr\004\000\000\000\000\346Tr\004\000\000\000\000J\314E\000\000\000\000\000\006\000\000\000\000\000\000\000P\267\017\004\000\000\000\000\000\000\000\000\002\000\000\000>\004F\000\000\000\000\000P#R\002\000\000\000\000\215\004F\000\000\000\000\000s\000\000\000\000\000\000\000P#R\002\000\000\000"
        value = <optimized out>
        line = <optimized out>
#12 0x000000000044c34a in hook_command_exec (buffer=buffer@entry=0x22f3500, any_plugin=any_plugin@entry=1, plugin=plugin@entry=0x0, string=string@entry=0x3c42c60 "/script unload matrix")
    at /home/flashcode/build/debian/weechat/src/core/wee-hook.c:803
        ptr_hook = <optimized out>
        next_hook = 0x0
        hook_plugin = 0x0
        hook_other_plugin = 0x2af9d10
        hook_other_plugin2 = 0x0
        hook_incomplete_command = 0x0
        argv = 0x497f750
        argv_eol = 0x45f8f30
        ptr_command_name = <optimized out>
        argc = 3
        rc = -1
        length_command_name = 6
        allow_incomplete_commands = 0
        count_other_plugin = 1
        count_incomplete_commands = 0
#13 0x0000000000452c7f in input_exec_command (buffer=buffer@entry=0x22f3500, any_plugin=any_plugin@entry=1, plugin=0x0, string=string@entry=0x4811ce0 "/script unload matrix")
    at /home/flashcode/build/debian/weechat/src/core/wee-input.c:107
        command = 0x3c42c60 "/script unload matrix"
        command_name = 0x419d440 "/script"
        pos = <optimized out>
        rc = 0
#14 0x00000000004530e4 in input_data (buffer=buffer@entry=0x22f3500, data=data@entry=0x42e1b70 "/script unload matrix") at /home/flashcode/build/debian/weechat/src/core/wee-input.c:270
        pos = 0x0
        buf = <optimized out>
        str_buffer = "0x22f3500\000\000\000\000\000\000\000\377\017\000\000\377\177\000\000\000\000\000\000\000\000\000\000p\034\200pb\177\000\000S\227\201pb\177\000\000N\000\000\000:\000\000\000 \026\345ob\177\000\000\026\000\000\000\000\000\000\000\000\065/\002\000\000\000\000\200\035N\002\000\000\000\000\037", '\000' <repeats 15 times>, "p\240\262ob\177", '\000' <repeats 11 times>"\330, D\002\000\000\000"
        new_data = 0x4811ce0 "/script unload matrix"
        buffer_full_name = 0x4b6afd0 "core.weechat"
        ptr_data = 0x4811ce0 "/script unload matrix"
        ptr_data_for_buffer = 0x0
        length = <optimized out>
        char_size = <optimized out>
        first_command = <optimized out>
        rc = <optimized out>
#15 0x000000000049c63f in plugin_api_command (plugin=<optimized out>, buffer=0x22f3500, command=0x244d800 "/script unload matrix") at /home/flashcode/build/debian/weechat/src/plugins/plugin-api.c:276
        command2 = 0x42e1b70 "/script unload matrix"
        rc = <optimized out>
#16 0x00007f626b440fe1 in relay_weechat_protocol_input_timer_cb (data=0x2234b10, remaining_calls=<optimized out>) at /home/flashcode/build/debian/weechat/src/plugins/relay/weechat/relay-weechat-protocol.c:381
        timer_args = 0x2234b10
        i = <optimized out>
        ptr_buffer = <optimized out>
#17 0x000000000044feaf in hook_timer_exec () at /home/flashcode/build/debian/weechat/src/core/wee-hook.c:1173
        tv_time = {tv_sec = 1429559346, tv_usec = 454531}
        ptr_hook = 0x2be93f0
        next_hook = 0x0
#18 0x00000000004664d8 in gui_main_loop () at /home/flashcode/build/debian/weechat/src/gui/curses/gui-curses-main.c:390
        hook_fd_keyboard = 0x24e1d80
        tv_timeout = {tv_sec = 0, tv_usec = 0}
        read_fds = {fds_bits = {0 <repeats 16 times>}}
        write_fds = {fds_bits = {0 <repeats 16 times>}}
        except_fds = {fds_bits = {0 <repeats 16 times>}}
        max_fd = <optimized out>
        ready = <optimized out>
#19 0x0000000000426bb5 in main (argc=<optimized out>, argv=<optimized out>) at /home/flashcode/build/debian/weechat/src/gui/curses/main.c:41
No locals.

@flashcode flashcode added the bug label Apr 20, 2015

@flashcode

This comment has been minimized.

Copy link
Member

flashcode commented Apr 22, 2015

I'm not able to reproduce the problem with the script matrix.lua loaded.
Do I have to connect to something with this script? If yes, can you give me quick commands to test and reproduce this freeze on unload?
Thanks.

@lorenzhs

This comment has been minimized.

Copy link
Author

lorenzhs commented Apr 22, 2015

I have no idea how to reproduce this, I unloaded it a few times before and it never hung. @torhve mentioned that he reloaded it countless times during development and never ran into any issue of the sorts. He also suspected that his script had already finished unloading at this point. I'm sorry that I can't be of more help.

EDIT: I dumped a core file before killing the instance, so if there's anything more I can do to help debug this I'll gladly try

@flashcode

This comment has been minimized.

Copy link
Member

flashcode commented Apr 22, 2015

In your backtrace, I have no idea why it freezes there, it's in a loop that is supposed to remove script hooks (and it should not make an infinite loop there).
So I'll close this issue; if ever you know how to reproduce the problem, you can comment on this issue or create a new one.

@flashcode flashcode closed this Apr 22, 2015

@flashcode flashcode self-assigned this Apr 22, 2015

@flashcode flashcode reopened this Apr 24, 2015

@flashcode

This comment has been minimized.

Copy link
Member

flashcode commented Apr 24, 2015

Problem is confirmed by at last 2 other users, so I reopen the ticket.

@torhve

This comment has been minimized.

Copy link
Contributor

torhve commented Jul 11, 2015

I reloaded my script today after having it running for a long time (many weeks) and saw a long hang:

1112  weechat       │ lua: unloading script "matrix"
1123  weechat       │ lua: script "matrix" unloaded

After that hang weechat operated normally again

@aji

This comment has been minimized.

Copy link

aji commented Aug 23, 2015

@torhve does the script call hook_command? if so, I may have insight into what the problem is. I'm currently writing a script to reproduce the issue

@aji

This comment has been minimized.

Copy link

aji commented Aug 23, 2015

https://gist.github.com/aji/73ee59d09124fd055099

this is a python script for weechat that reproduces the behavior seen

run /issue406 and /issue406url a few thousand times (e.g. with /repeat) and it's clear that there is a memory leak. a bit of inspection during the hang reveals weechat is hanging in the loop that releases hook_process callbacks.

scripts aren't usually running hook_process thousands of times a command like this, but there are a handful (such as http://github.com/aji/nya, where I first noticed the issue) that will call it every few seconds, which adds up over days and weeks.

EDIT: the issue may affect other hooks as well, but I haven't inspected any of them.

@torhve

This comment has been minimized.

Copy link
Contributor

torhve commented Aug 23, 2015

Yup, my script can easily call hook_process with URL thousand of times.

@torhve

This comment has been minimized.

Copy link
Contributor

torhve commented Feb 11, 2016

WeeChat just hung for 4 hours when trying to reload my script.

@torhve

This comment has been minimized.

Copy link
Contributor

torhve commented Mar 6, 2016

I did a /debug set core 2 and then a /lua unload matrix.

This is the core log, please notice several minutes pass within weechat code:

10:21:14     | debug: "core" => 2
10:21:19     | lua: unloading script "matrix"
10:21:19     | matrix: Unloading
10:21:19     | matrix: Saving olm state
10:21:19     | matrix: Clearing olm state from memory
10:21:19     | matrix: done cleaning up!
10:21:19     | debug: removing hook: type=4 (process), plugin=27f63c0 (lua)
10:21:19     | debug: removing hook: type=3 (fd), plugin=27f63c0 (lua)
10:21:19     | debug: removing hook: type=3 (fd), plugin=27f63c0 (lua)
10:21:19     | debug: removing hook: type=2 (timer), plugin=27f63c0 (lua)
10:24:02     | debug: removing hook: type=2 (timer), plugin=27f63c0 (lua)
10:24:02     | debug: removing hook: type=2 (timer), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=7 (signal), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=2 (timer), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=0 (command), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=9 (config), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=7 (signal), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: removing hook: type=1 (command_run), plugin=27f63c0 (lua)
10:24:03     | debug: adding hook: type=2 (timer), plugin=27f8530 (script), priority=1000
10:24:03     | lua: script "matrix" unloaded
10:24:03     | System clock skew detected (+164 seconds), reinitializing all timers
10:24:03     | debug: removing hook: type=2 (timer), plugin=27f8530 (script) 
@flashcode

This comment has been minimized.

Copy link
Member

flashcode commented Mar 20, 2016

The problem is that some hooks like hook_process (or hook_process_hashtable) are automatically removed by WeeChat core, and the script plugin is not notified.
So on script unload, hundreds or thousands of hooks are still associated with the script and it takes very long time to remove them.

@flashcode flashcode added this to the 1.5 milestone Mar 20, 2016

@flashcode flashcode closed this in cf6aca1 Mar 21, 2016

@flashcode flashcode removed the in progress label Mar 31, 2016

flashcode added a commit that referenced this issue Apr 28, 2016

arza-zara pushed a commit to arza-zara/weechat that referenced this issue Oct 4, 2016

core: add pointer in some callbacks (closes weechat#406)
This pointer is the first argument received by callbacks, and the
existing argument "data" is now automatically freed by WeeChat when the
object containing the callback is removed.

With this new pointer, the linked list of callbacks in scripts has been
removed. This will improve speed of scripts (using a lot of hooks),
reduce memory used by scripts and reduce time to unload scripts.

Following functions are affected in the C API:

* exec_on_files
* config_new
* config_new_section
* config_new_option
* hook_command
* hook_command_run
* hook_timer
* hook_fd
* hook_process
* hook_process_hashtable
* hook_connect
* hook_print
* hook_signal
* hook_hsignal
* hook_config
* hook_completion
* hook_modifier
* hook_info
* hook_info_hashtable
* hook_infolist
* hook_hdata
* hook_focus
* unhook_all_plugin
* buffer_new
* bar_item_new
* upgrade_new
* upgrade_read

arza-zara pushed a commit to arza-zara/weechat that referenced this issue Oct 4, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.