Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When running TestEvalScanner with -race=true, one can observe a data race such as: ``` WARNING: DATA RACE Read at 0x0000029f3d68 by goroutine 52: github.com/containous/yaegi/interp.(*itype).defaultType() /Users/mpl/src/github.com/containous/yaegi/interp/type.go:1466 +0x572 ... github.com/containous/yaegi/interp.(*Interpreter).EvalWithContext.func1() /Users/mpl/src/github.com/containous/yaegi/interp/interp.go:501 +0xf0 Previous write at 0x0000029f3d68 by goroutine 43: github.com/containous/yaegi/interp.(*itype).refType() /Users/mpl/src/github.com/containous/yaegi/interp/type.go:1419 +0x854 github.com/containous/yaegi/interp.(*itype).TypeOf() /Users/mpl/src/github.com/containous/yaegi/interp/type.go:1427 +0xa6 ... github.com/containous/yaegi/interp.(*Interpreter).EvalWithContext.func1() /Users/mpl/src/github.com/containous/yaegi/interp/interp.go:501 +0xf0 ``` Before this change, since closing the pipe to the REPL is done in a defer, it means that all the i.REPL calls (and hence each goroutine for each of these calls) are kept running and alive until the very end of the test. It should not matter, since a new interpreter is created for each test case, and thus all the i.REPL calls should be completely independent from each other. And yet, by wrapping each test case in a function call, and thus making each i.REPL call terminate as soon as the test case is over, the data race seems to be fixed. This could suggest that the separate i.REPL calls from separate interpreter instances are somehow sharing some memory, but I do not know how to explain that. The problem has yet to be fully understood, but at least this change restores the test, without making the CI fail again.
- Loading branch information