Skip to content

[Bug]: release pool fatal error #356

Open
@sunyuan300

Description

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?

释放pool偶现fatal error

Major version of ants

v2

Specific version of ants

v2.10.0

Operating system

Linux

OS version

Linux 6.1.27 x86_64

Go version

go version go1.23.1 linux/amd64

Relevant log output

unexpected fault address 0x0
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0xde8fb5]

goroutine 1563 gp=0xc0004b7c00 m=4 mp=0xc000071508 [running]:
runtime.throw({0x167d4ba?, 0x0?})
        /usr/lib/go/src/runtime/panic.go:1067 +0x48 fp=0xc000bb6898 sp=0xc000bb6868 pc=0x478f88
runtime.sigpanic()
        /usr/lib/go/src/runtime/signal_unix.go:931 +0x26c fp=0xc000bb68f8 sp=0xc000bb6898 pc=0x47afac
github.com/panjf2000/ants/v2.(*workerStack).reset(0xc00090cc90)
        /root/go-src/pkg/mod/github.com/panjf2000/ants/[email protected]/worker_stack.go:77 +0x55 fp=0xc000bb6928 sp=0xc000bb68f8 pc=0xde8fb5
github.com/panjf2000/ants/v2.(*Pool).Release(0xc000bb68e0?)
        /root/go-src/pkg/mod/github.com/panjf2000/ants/[email protected]/pool.go:303 +0xd5 fp=0xc000bb6948 sp=0xc000bb6928 pc=0xde72d5
...

Code snippets (optional)

func f(paths []string)([]string,error) {
	pool, err := ants.NewPool(runtime.NumCPU() * 5)
	if err != nil {
		logger.Errorf("err:%v", err)
		return nil, err
	}
	defer pool.Release()

	var (
		wg sync.WaitGroup
		result = make([]string,len(paths))
	)
	wg.Add(len(paths))

	for k, v := range paths {
		key := k
		val := v
		_ = pool.Submit(func() {
			defer wg.Done()
			// use key,val do something
		})
	}
	wg.Wait()
	return result,nil
}

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

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions