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

[Bug]: The worker pool will panic with WithPreAlloc(true) #358

Open
3 tasks done
arloliu opened this issue Feb 25, 2025 · 0 comments
Open
3 tasks done

[Bug]: The worker pool will panic with WithPreAlloc(true) #358

arloliu opened this issue Feb 25, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@arloliu
Copy link

arloliu commented Feb 25, 2025

Actions I've taken before I'm here

  • I've thoroughly read the documentations on this issue but still have no clue.
  • I've searched the current list of Github issues but didn't find any duplicate issues that have been solved.
  • I've searched the internet with this issue, but haven't found anything helpful.

What happened?

When creating worker pool with latest v2.11.1, regardless using multi pool or single pool.
The option WithPreAlloc(true) will cause panic runtime error: index out of range [0] with length 0 when call ReleaseWithTimeout() first, then call Reboot to reboot released pool.

E.g.,

workerPool.ReleaseTimeout(time.Second)
workerPool.Reboot()

It happens on worker_loop_queue.go:70, loopQueue.insert method.

Major version of ants

v2

Specific version of ants

v2.11.1

Operating system

Linux

OS version

Debian

Go version

go1.23.2

Relevant log output

[ants]: worker exits from panic: runtime error: index out of range [0] with length 0
goroutine 214 [running]:
runtime/debug.Stack()
        /home/arlo/.gvm/gos/go1.23.2/src/runtime/debug/stack.go:26 +0x67
github.com/panjf2000/ants/v2.(*goWorkerWithFuncGeneric[...]).run.func1.1()
        /home/arlo/.gvm/pkgsets/go1.23.2/global/pkg/mod/github.com/panjf2000/ants/[email protected]/worker_func_generic.go:65 +0x2a5
panic({0x1460f60?, 0xc000416600?})
        /home/arlo/.gvm/gos/go1.23.2/src/runtime/panic.go:785 +0x132
github.com/panjf2000/ants/v2.(*loopQueue).insert(0xc00042e6e0, {0x16bf5b0, 0xc0002c8200})
        /home/arlo/.gvm/pkgsets/go1.23.2/global/pkg/mod/github.com/panjf2000/ants/[email protected]/worker_loop_queue.go:70 +0x205
github.com/panjf2000/ants/v2.(*poolCommon).revertWorker(0xc00044ab60, {0x16bf5b0, 0xc0002c8200})
        /home/arlo/.gvm/pkgsets/go1.23.2/global/pkg/mod/github.com/panjf2000/ants/[email protected]/ants.go:516 +0x182
github.com/panjf2000/ants/v2.(*goWorkerWithFuncGeneric[...]).run.func1()
        /home/arlo/.gvm/pkgsets/go1.23.2/global/pkg/mod/github.com/panjf2000/ants/[email protected]/worker_func_generic.go:78 +0x276
created by github.com/panjf2000/ants/v2.(*goWorkerWithFuncGeneric[...]).run in goroutine 19
        /home/arlo/.gvm/pkgsets/go1.23.2/global/pkg/mod/github.com/panjf2000/ants/[email protected]/worker_func_generic.go:53 +0x111

Reproducer

How to Reproduce

Steps to reproduce the behavior:

  1. Go to '....'
  2. Click on '....'
  3. Do '....'
  4. See '....'

Does this issue reproduce with the latest release?

It can reproduce with the latest release

@arloliu arloliu added the bug Something isn't working label Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants