File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ import (
5757 "fmt"
5858 "net"
5959 "os"
60+ "runtime"
6061 "sync"
6162
6263 "github.com/cretz/bine/process"
@@ -149,6 +150,13 @@ var ErrNonzeroExitCode = errors.New("libtor: command completed with nonzero exit
149150// runtor runs tor until completion and ensures that tor exits when
150151// the given ctx is cancelled or its deadline expires.
151152func (p * torProcess ) runtor (ctx context.Context , cc net.Conn , args ... string ) {
153+ // make sure we lock to an OS thread otherwise the goroutine can get
154+ // preempted midway and cause data races
155+ //
156+ // See https://github.com/ooni/probe/issues/2406#issuecomment-1479138677
157+ runtime .LockOSThread ()
158+ defer runtime .UnlockOSThread ()
159+
152160 // wait for Start or context to expire
153161 select {
154162 case <- p .awaitStart :
You can’t perform that action at this time.
0 commit comments