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

mock普通成员函数会出段错误 #18

Closed
bingowzp opened this issue Feb 26, 2022 · 6 comments
Closed

mock普通成员函数会出段错误 #18

bingowzp opened this issue Feb 26, 2022 · 6 comments

Comments

@bingowzp
Copy link

系统信息:
Linux 4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

堆栈如下:
Program received signal SIGSEGV, Segmentation fault.
__memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:314
314 ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.
(gdb) bt
#0 __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:314
#1 0x00005555555f9286 in memcpy (__len=, __src=, __dest=) at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:34
#2 emock::JmpOnlyApiHookImpl::saveOriginalData (this=0x555555852bc0) at /usr1/home/00273119/tmp/emock-master/src/JmpOnlyApiHook.cpp:56
#3 emock::JmpOnlyApiHookImpl::startHook (this=0x555555852bc0) at /usr1/home/00273119/tmp/emock-master/src/JmpOnlyApiHook.cpp:62
#4 emock::JmpOnlyApiHookImpl::JmpOnlyApiHookImpl (stub=0x7ffff7ed100e, api=0x11e04, this=0x555555852bc0) at /usr1/home/00273119/tmp/emock-master/src/JmpOnlyApiHook.cpp:43
#5 emock::JmpOnlyApiHook::JmpOnlyApiHook (this=0x555555852ca0, api=0x11e04, stub=0x7ffff7ed100e) at /usr1/home/00273119/tmp/emock-master/src/JmpOnlyApiHook.cpp:89
#6 0x00005555555f479e in emock::ApiHookImpl::ApiHookImpl (stub=0x7ffff7ed100e, api=0x11e04, this=0x555555852ca0) at /usr1/home/00273119/tmp/emock-master/src/ApiHook.cpp:36
#7 emock::ApiHook::ApiHook (this=0x555555852cc0, api=0x11e04, stub=0x7ffff7ed100e) at /usr1/home/00273119/tmp/emock-master/src/ApiHook.cpp:48
#8 0x00005555555f423b in emock::ApiHookKey::ApiHookKey (this=0x555555852c20, api=0x11e04, holder=, isMemFun=) at /usr1/home/00273119/tmp/emock-master/src/ApiHookKey.cpp:38
#9 0x00005555555f3dd2 in emock::HookMockObjectImpl::addMethod (this=0x5555558514f0, name=..., api=0x11e04, hookHolder=0x555555852b80, ns=0x55555583ba80 emock::GlobalMockObject::instance,
isMemFun=) at /usr1/home/00273119/tmp/emock-master/src/HookMockObject.cpp:88
#10 0x00005555555f3f9e in emock::HookMockObjectImpl::getMethod (this=, name=..., api=, hookHolder=, ns=, isMemFun=)
at /usr1/home/00273119/tmp/emock-master/src/HookMockObject.cpp:110
#11 0x00005555555f3fc0 in emock::HookMockObject::method (this=, name=..., api=, hookHolder=, isMemFun=)
at /usr1/home/00273119/tmp/emock-master/src/HookMockObject.cpp:139
#12 0x000055555556aed6 in emock::InvocationMockBuilderGetter emock::mockAPI<int, ParkMaze, int, int>(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, int (ParkMaze::*)(int, int)) ()

@orca-zhang
Copy link
Member

收到反馈

@orca-zhang
Copy link
Member

看上去是跳板内存区域的选择没有保证在支持Enhanced REP MOVSB for memcpy的CPU上正确运行,需要做一下对齐处理,我再查查相关文章,然后尝试修复。

@bingowzp
Copy link
Author

bingowzp commented Mar 1, 2022

看上去是跳板内存区域的选择没有保证在支持Enhanced REP MOVSB for memcpy的CPU上正确运行,需要做一下对齐处理,我再查查相关文章,然后尝试修复。

成员函数原地址是0x555555564474,调用SymbolRetriever::getMethodAddress获取地址后变成了0x11e04的地址,这里有问题吗?

@orca-zhang
Copy link
Member

我加了一个降级处理,找不到跳板的情况下,默认用远跳,你试试看(不过对于太小的函数可能会导致错误覆盖后面的其他函数)

@orca-zhang
Copy link
Member

orca-zhang commented Aug 9, 2022

最近修复了ubuntu下,函数地址获取错误的问题,可以用最新版本尝试一下。

@orca-zhang
Copy link
Member

issue先关闭啦,如果还有问题可以reopen或者再开issue反馈哦,感谢反馈

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