Skip to content

Commit a427a4c

Browse files
committed
fixed panic: sync: WaitGroup is reused before previous Wait has returned 2022-10-11
1 parent 5bdfad9 commit a427a4c

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

brute/filefuzz.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package brute
33
import (
44
"context"
55
_ "embed"
6+
"fmt"
67
"github.com/antlabs/strsim"
78
"github.com/hktalent/ProScan4all/lib/util"
89
"github.com/hktalent/goSqlite_gorm/lib/scan/Const"
@@ -219,11 +220,15 @@ func FileFuzz(u string, indexStatusCode int, indexContentLength int, indexbody s
219220
//log.Printf("start fuzz: %s for", u)
220221
nStop := 400
221222
var lst200 *util.Response
223+
t001 := time.NewTicker(3 * time.Second)
224+
var nCnt int32 = 0
222225
go func() {
223226
for {
224227
select {
225228
case <-ctx2.Done():
226229
return
230+
case <-t001.C:
231+
fmt.Printf("(ok/total:%5d/%5d) (errs/limitErr:%3d/%3d) %s\r", nCnt, len(filedic), errorTimes, MaxErrorTimes, u)
227232
case x1, ok := <-async_data:
228233
if ok {
229234
if lst200 == nil || x1.Req.Resqonse.Body != lst200.Body {
@@ -266,6 +271,7 @@ func FileFuzz(u string, indexStatusCode int, indexContentLength int, indexbody s
266271
wg.Done() // 控制所有线程结束
267272
<-ch // 并发控制
268273
}()
274+
atomic.AddInt32(&nCnt, 1)
269275
for {
270276
select {
271277
case <-ctx.Done(): // 00-捕获所有线程关闭信号,并退出,close for all

engine/engineImp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func NewEngine(c *context.Context, pool int) *Engine {
3131
if nil != util.G_Engine {
3232
return util.G_Engine.(*Engine)
3333
}
34-
x1 := &Engine{Context: c, Wg: util.Wg, Pool: pool, EventData: make(chan *models.EventData, pool)}
34+
x1 := &Engine{Context: c, Wg: &sync.WaitGroup{}, Pool: pool, EventData: make(chan *models.EventData, pool)}
3535
p, err := ants.NewPoolWithFunc(pool, func(i interface{}) {
3636
defer x1.Wg.Done()
3737
x1.DoEvent(i.(*models.EventData))

webScan/Functions/Final.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ func final_ALLurl_ALLJson(urllist *[]string) {
134134
//results := make(chan bool, size+1)
135135
jobs_url := make(chan string, size+1)
136136
for i := 0; i < Configs.UserObject.ThreadNum; i++ {
137-
util.Wg.Add(1)
138137
util.DoSyncFunc(func() {
139-
defer util.Wg.Done()
140138
All_url_ALLjson(jobs_url, allresult)
141139
})
142140
}

0 commit comments

Comments
 (0)