-
Notifications
You must be signed in to change notification settings - Fork 60
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
the handle of inline is incorrect #77
Comments
@fumeboy, it is a bug, we could read funcId from objsymbolMap[inl.Func].Func.FuncID. |
could you give me a testcase for it |
我的意思是, 比如我内联了 fmt 包的一个函数, 但是我没有 fmt 包的 object file, 怎么能根据 symidx 找到它是哪个符号, 并获取 funcID 呢 我也很惊讶这样似乎也能正常运行; 我目前也构造不了错误 case |
是的,如果是外部包是无法得到信息的,所以如果查不到符号,用了默认值funcID_Normal |
要处理的话,golang1.12-1.15可以直接去读firstmodule的_func查到funcID,因为较早版本的obj里存了名字(但是1.15的名字是空的,应该是即将使用新的obj结构引入的问题); 1.16以后,就需要把fmt包读进来,才能知道相应的id是的symbol的名字是啥,现在对于外部包resolveSymRef回来的名字都是空字符串。 |
直接使用 FuncID_normal 没问题吗, 为什么呢 |
大部分情况下都是FuncID_normal ,实际上遇到的函数应该都是FuncID_normal 的, 而且这个inlineTree只在输出stack的时候用,对于执行应该没有太大的影响。 对于系统函数是错的,目前除了上面说的方案没有更好的方案. |
感觉并不是那么简单, 因为我看 inlineTree funcID 被 gentraceback 使用, gentraceback 应该和 GC 有关 |
是和栈相关,因为runtime.morestack, runtime.systemstack和cgocall会改变栈结构,所以需要特殊处理 |
看了下 funcID 的非 0 值对应的函数, 都不可能被内联, 那看来直接设置成 normal 是没问题的, 但既然如此为啥他们还要保留这个字段呢 .. |
这个玩意之前没有,1.12版本加进去的 |
the current handle in this repo is incorrect, it fills the caller's funcID instead of the callee's to the
InlinedCall.funcID
https://github.com/pkujhd/goloader/blob/master/inlinetree.go#L32
in go source code (go1.19.6), the funcID is got from other object file by
linker.Package[SymRef.Pkg][SymRef.SymIndex].funcID
but we cannot do this because we are unable to obtain these original Go object files used when compiling at runtime.
I suggest to use the
-l
option ofgo tool compile
to disable inlineThe text was updated successfully, but these errors were encountered: