-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
os/grpool: AddWithRecover Panic #3589
Comments
grpool.AddWithRecover 内 第二层 gtimer.SetInterval 里的错误无法捕获(正常,内部使用go func 实现),所以是gtimer需要改成 grpool.AddWithRecover 实现?还是文档备注一下 grpool.AddWithRecover 只能捕获第一层的panic错误,里层的不管 |
The error in the second layer gtimer.SetInterval in grpool.AddWithRecover cannot be captured (normal, internally implemented using go func), so gtimer needs to be changed to grpool.AddWithRecover? Let me make a note in the documentation: grpool.AddWithRecover can only capture panic errors in the first layer, and does not care about panic errors in the lower layers. |
Go version
1.21.6
GoFrame version
2.7.1
Can this bug be reproduced with the latest release?
Option Yes
What did you do?
_ = grpool.AddWithRecover(ctx, func(ctx context.Context) {
gtimer.SetInterval(ctx, 5*time.Second, func(ctx context.Context) {
err = service.CrmClientProtect().ProtectHandler(gctx.NeverDone(ctx))
if err != nil {
g.Dump(err)
}
g.Dump(err.Error()) // panic it
})
}, func(ctx context.Context, err error) {
g.Dump(err)
})
What did you see happen?
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: exception recovered: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x17a4a1e]
goroutine 104 [running]:
github.com/gogf/gf/v2/os/gtimer.(*Entry).Run.func1.1()
/Users/x/go/pkg/mod/github.com/gogf/gf/v2@v2.7.1/os/gtimer/gtimer_entry.go:55 +0x12e
panic({0x1889f60?, 0x21cc9c0?})
/usr/local/go/src/runtime/panic.go:914 +0x21f
lx_saas/internal/cmd.glob..func1.1.1({0x1ba3e38?, 0xc0005a3110})
/Users/x/GolandProjects/lx_saas/internal/cmd/cmd.go:48 +0xfe
github.com/gogf/gf/v2/os/gtimer.(*Entry).Run.func1()
/Users/x/go/pkg/mod/github.com/gogf/gf/v2@v2.7.1/os/gtimer/gtimer_entry.go:66 +0x54
created by github.com/gogf/gf/v2/os/gtimer.(*Entry).Run in goroutine 34
/Users/x/go/pkg/mod/github.com/gogf/gf/v2@v2.7.1/os/gtimer/gtimer_entry.go:48 +0x79
What did you expect to see?
预期是 grpool.AddWithRecover 能捕获panic,但是实际是 gtimer.SetInterval 使用了原生协程处理无法捕获
The text was updated successfully, but these errors were encountered: