From: Sergey Matveev Date: Tue, 27 Jan 2026 09:50:28 +0000 (+0300) Subject: Fix concurrent writes to map X-Git-Tag: v2.9.1^0 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2674597d6aae5629c8c2ba54a10e5324f1f1b06a;p=goredo.git Fix concurrent writes to map --- diff --git a/doc/INSTALL b/doc/INSTALL index c488783..b567c43 100644 --- a/doc/INSTALL +++ b/doc/INSTALL @@ -11,7 +11,7 @@ Possibly goredo package already exists for your distribution: Preferable way is to [Download] tarball with the signature from website: - $ v=2.9.0 + $ v=2.9.1 $ [fetch|wget] http://www.goredo.cypherpunks.su/download/goredo-$v.tar.zst $ [fetch|wget] http://www.goredo.cypherpunks.su/download/goredo-$v.tar.zst.{asc,sig,cm} [Integrity] verify diff --git a/doc/NEWS b/doc/NEWS index 636ae78..c07eb91 100644 --- a/doc/NEWS +++ b/doc/NEWS @@ -1,3 +1,7 @@ +A 2.9.1 +2.9.1 + * Fix possible panic. + A 2.9.0 2.9.0 * Warn if non-top target did not write anything. diff --git a/main.go b/main.go index 52bb679..012da2e 100644 --- a/main.go +++ b/main.go @@ -318,6 +318,7 @@ func main() { go func() { <-killed tracef(CDebug, "[%s] killed", BuildUUID) + TmpsToCleanM.Lock() for fn := range TmpsToClean { tracef(CDebug, "[%s] clean tempfile: %s", BuildUUID, fn) os.Remove(fn) diff --git a/run.go b/run.go index 7db6752..7d0c66a 100644 --- a/run.go +++ b/run.go @@ -71,6 +71,7 @@ var ( StopIfMod = false Jobs sync.WaitGroup TmpsToClean = make(map[string]struct{}) + TmpsToCleanM sync.Mutex flagTrace *bool flagTraceAll *bool @@ -320,7 +321,11 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error { lockRelease() return TgtError{tgt, ErrLine(err)} } - TmpsToClean[fdDep.Name()] = struct{}{} + { + TmpsToCleanM.Lock() + TmpsToClean[fdDep.Name()] = struct{}{} + TmpsToCleanM.Unlock() + } fdDepOpened := true fdDepExists := true fdDepW := bufio.NewWriter(fdDep) @@ -330,7 +335,11 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error { fdDep.Close() } if fdDepExists { - delete(TmpsToClean, fdDep.Name()) + { + TmpsToCleanM.Lock() + delete(TmpsToClean, fdDep.Name()) + TmpsToCleanM.Unlock() + } os.Remove(fdDep.Name()) } } @@ -410,7 +419,11 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error { cleanup() return TgtError{tgt, ErrLine(err)} } - TmpsToClean[fdStdout.Name()] = struct{}{} + { + TmpsToCleanM.Lock() + TmpsToClean[fdStdout.Name()] = struct{}{} + TmpsToCleanM.Unlock() + } fdStdout.Close() tmpPath := fdStdout.Name() + ".3" // and for $3 tmpPathRel := mustRel(cwd, tmpPath) @@ -611,13 +624,19 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error { } lockRelease() if fdDepExists { - delete(TmpsToClean, fdDep.Name()) os.Remove(fdDep.Name()) } - delete(TmpsToClean, fdStdout.Name()) os.Remove(fdStdout.Name()) - delete(TmpsToClean, tmpPath) os.Remove(tmpPath) + { + TmpsToCleanM.Lock() + if fdDepExists { + delete(TmpsToClean, fdDep.Name()) + } + delete(TmpsToClean, fdStdout.Name()) + delete(TmpsToClean, tmpPath) + TmpsToCleanM.Unlock() + } if FdStatus != nil { if _, err = FdStatus.Write([]byte{StatusDone}); err != nil { log.Fatal(err) @@ -841,7 +860,11 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error { if err != nil { goto Finish } - delete(TmpsToClean, fdDep.Name()) + { + TmpsToCleanM.Lock() + delete(TmpsToClean, fdDep.Name()) + TmpsToCleanM.Unlock() + } fdDepExists = false if !NoSync { err = ErrLine(syncDir(redoDir)) diff --git a/usage.go b/usage.go index d18f8f1..3e66699 100644 --- a/usage.go +++ b/usage.go @@ -24,7 +24,7 @@ import ( ) const ( - Version = "2.9.0" + Version = "2.9.1" Warranty = `Copyright (C) 2020-2026 Sergey Matveev This program is free software: you can redistribute it and/or modify