failpoint doesn't work if the marker function is defined in the main package
还没有人认领这个 Issue。
评估
调研方向
先查看运行 failpoint-ctl enable 后生成的 main.go 和 binding__failpoint_binding__.go。使用 go run main.go 重现问题,并检查生成的 curpkg 符号为何不可用。当示例能够编译,并在启用 failpoint 时发生 panic,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Bug Report
Please answer these questions before submitting your issue. Thanks!
- What did you do? If possible, provide a recipe for reproducing the error.
For example, we have a file named main.go:
package main
import (
"github.com/pingcap/failpoint"
)
func F1(name string) string {
failpoint.Inject("failpoint-name", nil)
return "hello " + name
}
func main() {
failpoint.Enable("failpoint-name", "panic")
F1("ttt")
}
After transfrom the code with failpoint-ctl enable, the generated binding__failpoint_binding__.go looks like this:
package main
import "reflect"
type __failpointBindingType struct {pkgpath string}
var __failpointBindingCache = &__failpointBindingType{}
func init() {
__failpointBindingCache.pkgpath = reflect.TypeOf(__failpointBindingType{}).PkgPath()
}
func _curpkg_(name string) string {
return __failpointBindingCache.pkgpath + "/" + name
}
You may notice that binding__failpoint_binding__.go is also in package main, that means binding__failpoint_binding__.go could not be found by main.go.
Run go run main.go then, you will find the following error:
./main.go:8:17: undefined: _curpkg_
- What did you expect to see?
program panics due to failpoint
- What did you see instead?
./main.go:8:17: undefined: _curpkg_
- Versions of the failpoint
$ ./bin/failpoint-ctl -V
ReleaseVersion bf45ab2
BuildTS 2019-05-15 09:48:44
GitHash bf45ab20bfc48d624b61944a4820768c16d7db99
GitBranch master
GoVersion go version go1.12 darwin/amd64
- 主要语言
- Go
- 星标
- 896
- 派生
- 69
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pingcap/failpoint 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 30/100
-
expect `Enable()` inTerm:'off' does not trigger failpoint code, but it's not as expect可能已有人在做 @1fanwang 于 30 天前认领。 未关闭bug
难度 3/5 1-2 天 新手友好度 45/100
-
question
难度 3/5 1-2 天 新手友好度 35/100
-
bug
难度 3/5 1-2 天 新手友好度 35/100
-
bug
难度 3/5 1-2 天 新手友好度 45/100
查看 pingcap/failpoint 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 60/100
-
✨ Propose the missing gate after three same-class findings instead of filing a fourth可能已有人在做 @hivecommons-hive 今天认领。 未关闭enhancement help wanted hive/claimed-by-scanner stage/040-covered-by-pr
难度 2/5 1-3 小时 新手友好度 72/100
hivecommons/hive#13428 · 3 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
🕷️ bug
难度 2/5 1-3 小时 新手友好度 70/100
sysadminsmedia/homebox#1805 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100