Skip to content

Commit

Permalink
check whether pinning to the OS thread fixes the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Mar 22, 2023
1 parent 8a0118d commit 51292a4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/libtor/enabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ var ErrNonzeroExitCode = errors.New("libtor: command completed with nonzero exit
// runtor runs tor until completion and ensures that tor exits when
// the given ctx is cancelled or its deadline expires.
func (p *torProcess) runtor(ctx context.Context, cc net.Conn, args ...string) {
// make sure we lock to an OS thread otherwise the goroutine can get
// preempted midway and cause data races
//
// See https://github.com/ooni/probe/issues/2406#issuecomment-1479138677
runtime.LockOSThread()
defer runtime.UnlockOSThread()

// wait for Start or context to expire
select {
case <-p.awaitStart:
Expand Down

0 comments on commit 51292a4

Please sign in to comment.