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

自动同步会导致fcitx5崩溃? #280

Closed
HowcanoeWang opened this issue Oct 15, 2023 · 6 comments
Closed

自动同步会导致fcitx5崩溃? #280

HowcanoeWang opened this issue Oct 15, 2023 · 6 comments

Comments

@HowcanoeWang
Copy link

HowcanoeWang commented Oct 15, 2023

不确定是我开发的这个插件的原因,还是前几天manjaro源更新的原因,fcitx输入法每隔半小时(每小时的37分和07分)就准时崩溃一次。但开启插件使用是完全正常的。

然后使用命令行查看,有如下的报错输出:

$ fcitx5  
I2023-10-15 13:37:46.600670 instance.cpp:1318] Override Enabled Addons: {}
I2023-10-15 13:37:46.600751 instance.cpp:1319] Override Disabled Addons: {}
I2023-10-15 13:37:46.602596 xcbconnection.cpp:185] Connecting to X11 display, display name::0.
I2023-10-15 13:37:46.602690 addonmanager.cpp:193] Loaded addon xcb
I2023-10-15 13:37:46.603309 addonmanager.cpp:193] Loaded addon quickphrase
I2023-10-15 13:37:46.603375 addonmanager.cpp:193] Loaded addon imselector
I2023-10-15 13:37:46.606275 addonmanager.cpp:193] Loaded addon keyboard
I2023-10-15 13:37:46.607323 addonmanager.cpp:193] Loaded addon dbus
I2023-10-15 13:37:46.610970 addonmanager.cpp:193] Loaded addon fcitx4frontend
I2023-10-15 13:37:46.611880 addonmanager.cpp:193] Loaded addon ibusfrontend
I2023-10-15 13:37:46.612449 addonmanager.cpp:193] Loaded addon xim
E2023-10-15 13:37:46.614605 waylandmodule.cpp:227] Failed to open wayland connection
I2023-10-15 13:37:46.614631 addonmanager.cpp:193] Loaded addon wayland
I2023-10-15 13:37:46.615345 addonmanager.cpp:193] Loaded addon dbusfrontend
I2023-10-15 13:37:46.615826 addonmanager.cpp:193] Loaded addon clipboard
I2023-10-15 13:37:46.616047 addonmanager.cpp:193] Loaded addon waylandim
I2023-10-15 13:37:46.616204 addonmanager.cpp:193] Loaded addon unicode
I2023-10-15 13:37:46.616679 addonmanager.cpp:193] Loaded addon pinyinhelper
I2023-10-15 13:37:46.642598 inputmethodmanager.cpp:198] Found 735 input method(s) in addon keyboard
I2023-10-15 13:37:46.678704 addonmanager.cpp:193] Loaded addon kimpanel
I2023-10-15 13:37:46.679006 addonmanager.cpp:193] Loaded addon virtualkeyboard
I2023-10-15 13:37:46.696970 classicui.cpp:67] Created classicui for x11 display::0
I2023-10-15 13:37:46.696994 addonmanager.cpp:193] Loaded addon classicui
I2023-10-15 13:37:46.697246 addonmanager.cpp:193] Loaded addon notificationitem
I2023-10-15 13:37:46.697437 addonmanager.cpp:193] Loaded addon notifications
I2023-10-15 13:37:46.697790 kimpanel.cpp:113] Kimpanel new owner: 
I2023-10-15 13:37:46.697808 virtualkeyboard.cpp:220] VirtualKeyboard new owner: 
I2023-10-15 13:37:47.893920 addonmanager.cpp:193] Loaded addon rime
I2023-10-15 14:07:46.645572 instance.cpp:1179] Running autosave...
=========================
Fcitx 5.1.1 -- Get Signal No.: 11
Date: try "date -d @1697346466" if you are using GNU date ***
ProcessID: 24537
fcitx5(+0x1030c)[0x55bbf21df30c]
/usr/lib/libc.so.6(+0x3e710)[0x7f6a8f05c710]
/usr/lib/liblua.so.5.4(lua_rawgeti+0x13)[0x7f6a87ab45f3]
/usr/lib/liblua.so.5.4(luaL_unref+0x34)[0x7f6a87ad07f4]
/usr/lib/rime-plugins/librime-lua.so(_ZN6LuaObjD2Ev+0x19)[0x7f6a857aca69]
/usr/lib/rime-plugins/librime-lua.so(+0x98a87)[0x7f6a857aca87]
/usr/lib/rime-plugins/librime-lua.so(+0x2e997)[0x7f6a85742997]
/usr/lib/rime-plugins/librime-lua.so(+0x88988)[0x7f6a8579c988]
/usr/lib/rime-plugins/librime-lua.so(+0x38d4a)[0x7f6a8574cd4a]
/usr/lib/rime-plugins/librime-lua.so(+0x89cfc)[0x7f6a8579dcfc]
/usr/lib/rime-plugins/librime-lua.so(+0x89ae9)[0x7f6a8579dae9]
/usr/lib/rime-plugins/librime-lua.so(+0x38d4a)[0x7f6a8574cd4a]
/usr/lib/rime-plugins/librime-lua.so(+0x882b0)[0x7f6a8579c2b0]
/usr/lib/librime.so.1(+0x85bda)[0x7f6a87e96bda]
/usr/lib/librime.so.1(+0xa134a)[0x7f6a87eb234a]
/usr/lib/librime.so.1(+0x85bda)[0x7f6a87e96bda]
/usr/lib/librime.so.1(_ZN4rime6EngineD1Ev+0xd9)[0x7f6a87eac2a9]
/usr/lib/librime.so.1(_ZN4rime14ConcreteEngineD0Ev+0xe)[0x7f6a87eacb0e]
/usr/lib/librime.so.1(+0x86367)[0x7f6a87e97367]
/usr/lib/librime.so.1(+0x1749da)[0x7f6a87f859da]
/usr/lib/librime.so.1(_ZN4rime7Service18CleanupAllSessionsEv+0x20)[0x7f6a87ebf600]
/usr/lib/librime.so.1(RimeSyncUserData+0x2e)[0x7f6a87e9b6fe]
/usr/lib/fcitx5/rime.so(+0xaede)[0x7f6a8c113ede]
/usr/lib/libFcitx5Core.so.7(_ZN5fcitx12AddonManager7saveAllEv+0x6d)[0x7f6a8f7712cd]
/usr/lib/libFcitx5Core.so.7(+0x55ce2)[0x7f6a8f74cce2]
/usr/lib/libFcitx5Utils.so.2(+0x41a56)[0x7f6a8f66da56]
/usr/lib/libsystemd.so.0(+0x83f54)[0x7f6a8f507f54]
/usr/lib/libsystemd.so.0(sd_event_dispatch+0x11e)[0x7f6a8f5082de]
/usr/lib/libsystemd.so.0(sd_event_run+0x119)[0x7f6a8f509fe9]
/usr/lib/libsystemd.so.0(sd_event_loop+0x60)[0x7f6a8f50a1c0]
/usr/lib/libFcitx5Utils.so.2(_ZN5fcitx9EventLoop4execEv+0x16)[0x7f6a8f66b7f6]
/usr/lib/libFcitx5Core.so.7(_ZN5fcitx8Instance4execEv+0x57)[0x7f6a8f73c5e7]
zsh: segmentation fault (core dumped)  fcitx5

感觉最大的可能是定时自动同步的问题,不确定在这边反馈对不对,但是崩溃报告里确实有librime-lua.so,先在这边咨询一下,感谢大佬们的解答!

@hchunhui
Copy link
Owner

比较可能是用了 select_notifier 的原因。我看你的插件是每次调用 filter 都会建立一个新的 notifier,这些新建的 notifier 是依靠 gc 回收时断开的。librime 同步是可能需要重新初始化 engine,如果同步正好落在 notifier 被 gc 之前,那么 notifier 里面的 engine 就过期了,产生悬空引用。

@hchunhui
Copy link
Owner

不知道是否可以把 notifier 的注册放到 init() 里面,然后在 fini() 里面手动断开

@HowcanoeWang
Copy link
Author

比较可能是用了 select_notifier 的原因。我看你的插件是每次调用 filter 都会建立一个新的 notifier,这些新建的 notifier 是依靠 gc 回收时断开的。librime 同步是可能需要重新初始化 engine,如果同步正好落在 notifier 被 gc 之前,那么 notifier 里面的 engine 就过期了,产生悬空引用。

确实,我把插件停用了之后,自动同步就能正常进行:

I2023-10-15 14:21:11.479027 addonmanager.cpp:193] Loaded addon rime
I2023-10-15 14:51:10.446784 instance.cpp:1179] Running autosave...
I2023-10-15 14:51:10.463585 instance.cpp:1181] End autosave

不知道是否可以把 notifier 的注册放到 init() 里面,然后在 fini() 里面手动断开

这个算是Lua的类写法?刚接触lua不是很清楚应该怎么修改比较好,目前暂时只会根据wiki上的教程把函数传递过去

@HowcanoeWang
Copy link
Author

参考这边的代码我改改看:

function P.init(env)
print( "** init Processor",env.name_space )
env.ncomps={
"ascii_composer",
"recognizer",
"key_binder",
"speller",
"punctuator",
"selector",
"navigator",
}
env.comps={}
for i,v in ipairs(env.ncomps) do
local comp=Component.Processor(env.engine,"",v)
assert(comp,"failed : create processor of " .. v)
table.insert(env.comps, Component.Processor(env.engine,"",v))
end
-- option: editor_mode change editor_mode
env.neditors={
"express_editor",
"fluid_editor",
}
local function gen_editor(env)
local mode = env.engine.context:get_option("editor_mode") and 2 or 1
print("** " ,env.neditors[mode])
env.editor= Component.Processor(env.engine,"",env.neditors[mode])
end
gen_editor(env)
env.notifier = env.engine.context.option_update_notifier:connect(
function(ctx,name)
if name =="editor_mode" then
gen_editor(env)
end
end)
end
function P.fini(env)
env.notifier:disconnect()
end
function P.func(key,env)
local context = env.engine.context
local key = KeyEvent(key:repr() )
local Rejected,Accepted,Noop= 0,1,2
for i,v in ipairs(env.comps) do
res = v:process_key_event(key)
if res == Rejected or res == Accepted then
return res
end
end
return env.editor:process_key_event(key)
end

@hchunhui
Copy link
Owner

hchunhui commented Oct 15, 2023

不知道是否可以把 notifier 的注册放到 init() 里面,然后在 fini() 里面手动断开

这个算是Lua的类写法?刚接触lua不是很清楚应该怎么修改比较好,目前暂时只会根据wiki上的教程把函数传递过去

不是 lua 通用的写法,是本项目的特殊约定。请见
https://github.com/hchunhui/librime-lua/wiki/Scripting#lua_filter
里面的“完整形式”。

HowcanoeWang added a commit to HowcanoeWang/rime-lua-aux-code that referenced this issue Oct 15, 2023
@HowcanoeWang
Copy link
Author

感谢回复,经过修改确实不会崩溃了。而且通过控制台输出可以判断,保存的时候确实会初始化一遍:

** AuxCode filter       aux_filter
** AuxCode filter       read Aux code txt:      ZRM_Aux-code_4.3.txt
I2023-10-15 15:57:42.446871 instance.cpp:1179] Running autosave...
I2023-10-15 15:57:42.459369 instance.cpp:1181] End autosave
** AuxCode filter       aux_filter
** AuxCode filter       read Aux code txt:      ZRM_Aux-code_4.3.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants