panjf2000 / ants

🐜🐜🐜 ants is the most powerful and reliable pooling solution for Go.
https://ants.andypan.me/
MIT License
12.51k stars 1.34k forks source link

Panic occurred when using nested pools #86

Closed coolcode-ws closed 4 years ago

coolcode-ws commented 4 years ago

call chain :

pool1:
    antsP, _ := ants.NewPoolWithFunc(len(block.GetTransactions()), func(params interface{}) {
        syncVerify1(params) //handle some verify, this func define another ants pool
        xxxx
    })
    defer antsP.Release()
pool2:
      syncVerify1(params{
            xxxx
           antsP1, _ := ants.NewPoolWithFunc(len(block.GetTransactions()), func(params interface{}) {
        syncVerify2(params)
        xxx
    })
    defer antsP1.Release()//problems happens
      }

debug info like this:

2020/04/14 17:50:05 worker with func exits from a panic: runtime error: invalid memory address or nil pointer dereference
2020/04/14 17:50:05 worker with func exits from panic: goroutine 55 [running]:
github.com/panjf2000/ants.(*goWorkerWithFunc).run.func1.1(0xc000165b30)
        /data/home/go_workspace/src/trustsql-spv-go/vendor/github.com/panjf2000/ants/worker_func.go:59 +0x140
panic(0xf859e0, 0x18950d0)
        /usr/local/go/src/runtime/panic.go:679 +0x1b2
github.com/panjf2000/ants.(*PoolWithFunc).Release(0x0)
        /data/home/go_workspace/src/trustsql-spv-go/vendor/github.com/panjf2000/ants/pool_func.go:221 +0x22
trustsql-spv-go/validator.Validator.AsyncVerifyBlock(0x0, 0x1, 0xc000196090, 0x25, 0xc00016e4f0, 0xf, 0x1, 0x1, 0x0, 0x0, ...)
        /data/home/go_workspace/src/trustsql-spv-go/validator/validatator.go:113 +0x3b3
trustsql-spv-go/storage.(*BlocksDaoImpl).AsyncStoreBlocks.func1(0xfbef60, 0xc0001dc6e0)
        /data/home/go_workspace/src/trustsql-spv-go/storage/block_dao_impl.go:163 +0x239
trustsql-spv-go/storage.(*BlocksDaoImpl).AsyncStoreBlocks.func2(0xfbef60, 0xc0001dc6e0)
        /data/home/go_workspace/src/trustsql-spv-go/storage/block_dao_impl.go:171 +0x42
github.com/panjf2000/ants.(*goWorkerWithFunc).run.func1(0xc000165b30)
        /data/home/go_workspace/src/trustsql-spv-go/vendor/github.com/panjf2000/ants/worker_func.go:71 +0xbd
created by github.com/panjf2000/ants.(*goWorkerWithFunc).run
        /data/home/go_workspace/src/trustsql-spv-go/vendor/github.com/panjf2000/ants/worker_func.go:49 +0x4c
panjf2000 commented 4 years ago

You should fill out the template of the bug report, now you just erase it and add your info, which puts me in the position of not knowing anything about your local environment.

I don't even know what OS you were running on, what version of ants you were using, etc.