rime / librime

Rime Input Method Engine, the core library
https://rime.im
BSD 3-Clause "New" or "Revised" License
3.37k stars 551 forks source link

Twice librime initialize cause glog error #782

Closed zhaozg closed 9 months ago

zhaozg commented 10 months ago

Describe the bug

Multi times call initialize will get error.

https://github.com/zhaozg/rime_lua/actions/runs/7239083738/job/19720573177#step:4:941

To Reproduce Steps to reproduce the bug:

github ci at https://github.com/zhaozg/rime_lua/blob/master/.github/workflows/ci.yml

error output please look at here

Expected behavior Not hit this error report.

Log If applicable, add crash log to quick focus your problem.

F20231217 14:22:46.504894 18244 utilities.cc:365] Check failed: !IsGoogleLoggingInitialized() You called InitGoogleLogging() twice!
*** Check failure stack trace: ***
    @        0x10ebed56f  google::LogMessageFatal::~LogMessageFatal()
    @        0x10ebe92d9  google::LogMessageFatal::~LogMessageFatal()
    @        0x10ebf3615  google::glog_internal_namespace_::InitGoogleLoggingUtilities()
    @        0x10e164979  main
    @        0x10e1b450e  luaL_openlibs
    @        0x10e162516  main
    @        0x10e16ece2  lua_pcall
    @        0x10e160487  main
    @        0x10e15fe76  main
    @        0x10e162516  main
    @        0x10e16ed23  lua_cpcall
    @        0x10e15f793  main
/Users/runner/work/_temp/3f4987b9-9161-4c71-81c3-d4f8e11f8361.sh: line 1:  5565 Abort trap: 6  

Screenshots If applicable, add screenshots to help explain your problem.

Flavor(please complete the following information): Select your flavor:

Package:

Additional context Add any other context about the problem here.

lotem commented 9 months ago

Sorry, I don't understand why you want to call it twice.

RimeSetupLogging should only be called once at program start. If called more than once, the program logic could be wrong, and the error is desired.

If you don't intend to call it twice, then please find the root cause, not mute the error.

zhaozg commented 9 months ago

librime 是我的唯一使用的输入法, 首先表示感谢。

我基于 librime 的 lua 绑定 进行一些单元/功能测试。 已注意到 librime 提供了 initialize/finalize 的接口封装,每个测试用例执行前调用了 initialize, 执行后调用了 finalize, 从头文件暴露的接口来看,librime应该支持多次初始化的, 但是 glog 不支持多次初始化,抛出了当前问题中描述的,也没发现glog有类似于 finalize的接口。

我没有直接调用过RimeSetupLogging, 而是调用了RimeSetup, 通过 https://github.com/rime/librime/blob/de12d6ae52ea0439ac689a9469b7041653a19fd5/src/rime_api.cc#L52 可知,SetupLogging在此处调用了。 RimeSetup 的多次调用导致了该问题。

多次调用RimeSetup的目的是为单元测试加载不同的配置与数据,写到这里我怀疑是自己的调用不当造成的,RimeSetup也不应该多次调用,而是通过调用RimeInitialize来加载不同的配置。

我继续修改下自己的代码,跟踪分析下, 该问题验证后我会关闭掉。