rime / weasel

【小狼毫】Rime for Windows
https://rime.im
GNU General Public License v3.0
4.44k stars 543 forks source link

程序结束时系统卸载Weasel.dll抛出内存访问冲突异常 #1293

Closed YukiIsait closed 3 months ago

YukiIsait commented 4 months ago

上报前请检查

操作系统信息

描述遇到的问题

程序被系统自动加载weasel.dll后,程序结束时系统卸载DLL抛出未经处理的内存访问冲突异常如下:

Unhandled exception at 0x00007FFEB155F048 (weasel.dll) in Shim.exe: 0xC0000005: Access violation reading location 0x0000000000000068.

调用栈如下:

weasel.dll!boost::serialization::singleton<class std::multiset<class boost::serialization::typeid_system::extended_type_info_typeid_0 const *,struct boost::serialization::typeid_system::type_compare,class std::allocator<class boost::serialization::typeid_system::extended_type_info_typeid_0 const *> > >::get_instance(void)
weasel.dll!boost::serialization::typeid_system::extended_type_info_typeid_0::type_unregister(void)
[Inline Frame] weasel.dll!boost::serialization::extended_type_info_typeid<weasel::UIStyle>::{dtor}() Line 96
[Inline Frame] weasel.dll!boost::serialization::detail::singleton_wrapper<boost::serialization::extended_type_info_typeid<weasel::UIStyle>>::{dtor}() Line 152
weasel.dll!`boost::serialization::singleton<boost::serialization::extended_type_info_typeid<weasel::UIStyle>>::get_instance'::`2'::`dynamic atexit destructor for 't''()
weasel.dll!_execute_onexit_table::__l2::<lambda>() Line 206
weasel.dll!__crt_seh_guarded_call<int>::operator()<<lambda_7777bce6b2f8c936911f934f8298dc43>,int <lambda>(void) &,<lambda_3883c3dff614d5e0c5f61bb1ac94921c>>(__acrt_lock_and_call::__l2::<lambda_7777bce6b2f8c936911f934f8298dc43> && setup, _execute_onexit_table::__l2::int <lambda>(void) & action, __acrt_lock_and_call::__l2::<lambda_3883c3dff614d5e0c5f61bb1ac94921c> && cleanup) Line 204
[Inline Frame] weasel.dll!__acrt_lock_and_call(const __acrt_lock_id) Line 974
weasel.dll!_execute_onexit_table(_onexit_table_t * table) Line 160
weasel.dll!common_exit::__l2::<lambda>() Line 226
weasel.dll!__crt_seh_guarded_call<void>::operator()<<lambda_d80eeec6fff315bfe5c115232f3240e3>,void <lambda>(void) &,<lambda_2358e3775559c9db80273638284d5e45>>(__acrt_lock_and_call::__l2::<lambda_d80eeec6fff315bfe5c115232f3240e3> && setup, common_exit::__l2::void <lambda>(void) & action, __acrt_lock_and_call::__l2::<lambda_2358e3775559c9db80273638284d5e45> && cleanup) Line 224
[Inline Frame] weasel.dll!__acrt_lock_and_call(const __acrt_lock_id) Line 974
weasel.dll!common_exit(const int return_code, const _crt_exit_cleanup_mode cleanup_mode, const _crt_exit_return_mode return_mode) Line 195
weasel.dll!__scrt_dllmain_uninitialize_c() Line 407
weasel.dll!dllmain_crt_process_detach(const bool is_terminating) Line 182
weasel.dll!dllmain_dispatch(HINSTANCE__ * const instance, const unsigned long reason, void * const reserved) Line 293

复现步骤

  1. 打开Shim.exe软件
  2. Shim.exe运行结束
  3. weasel.dll内存访问冲突异常

预期行为

期望weasel.dll正常DETACH

用户文件

RimeData.zip

截图

其他补充说明

问题程序的编译工具链为Visual Studio 2017 - Windows XP (v141_xp),关闭了GS安全检查,指定了程序入口点为EntryPoint,如果不写任何代码并在EntryPoint直接返回,不会触发weasel.dll异常。

fxliang commented 4 months ago

提供最小程序代码工程,才有可能有后面的可能

YukiIsait commented 4 months ago

提供最小程序代码工程,才有可能有后面的可能

好的,已上传

最小代码工程.zip

fxliang commented 3 months ago

两个点 1.为什么要指定EntryPoint? 2.为什么要禁用GS?

试了下,只要正经一点用WinMain做入口,就没有问题,大概是WinMain附带了一些dll处理释放的事项? 如果你要写得这么不一样,应该可能对Windows内部编程有很深入的了解,就要对它随之的可能问题负责了。

我试过只要在退出前手动将加载的dll free掉,就不会有这个异常。

所以,我认为这个不是输入法的问题。