delve icon indicating copy to clipboard operation
delve copied to clipboard

Function call injection failures on Travis-CI

Open aarzilli opened this issue 5 years ago • 3 comments
trafficstars

Travis-CI has updated its macOS builders to 10.13.6 (from ???) and now call injection tests are failing with the error:

Call - could not restore registers: protocol error E32 during register write for packet $P7b=03000000;thread...

The cause of this error is possibly inside debugserver but it could also be that we are doing something wrong. Somebody with access to a system that can replicate this issue should investigate this problem.

aarzilli avatar Dec 27 '19 14:12 aarzilli

We also get a similar error during GoLand integration tests on linux. The test debugs the following program and once breakpoint is reached calls SliceResult():

package main

type T struct {
	f string
}

type T2 struct {
	T
}

func (t T) MethodNoResults() {
	println("foo")
}

func (t T) MethodOneResult() string {
	return "ok" //position MethodOneResult
}

func (t T) MethodManyUnnamedResults() (string, int, bool) {
	return "ok", 42, false
}

func (t T) MethodManyNamedResults() (one string, two int, three bool) {
	return "ok", 42, false
}

func (t T) UnusedMethod() int {
	return 0
}

func UnusedFunc() int {
	return 0
}

func FuncOneResult() string {
	return "ok"
}

func Factorial(n int) int {
	if n == 0 {
		return 1 //position fact1
	} else {
		return n * Factorial(n - 1) //position fact2
	}
}

func Panic(b bool) {
	if b {
		panic("panic value")
	}
}

func SliceResult() []string {
	return []string{"one", "two"}
}

func BigSliceResult() []int {
	var result []int
	for i := 0; i < 1000; i++ {
		result = append(result, i)
	}
	return result
}

func main() {
	t := T{"ok"}
	t2 := T2{}
	_ = FuncOneResult()
	_ = t.MethodOneResult()
	_, _, _ = t.MethodManyUnnamedResults()
	_, _, _ = t.MethodManyNamedResults()
	_ = SliceResult()
	_ = BigSliceResult()
	_ = t2.MethodOneResult()
	t.MethodNoResults() //break
	_ = Factorial(1)
	Panic(false)
}

Full rpc log is here: https://gist.github.com/nd/6da1b41d356beefe3746c5aa652929ba. Can any other logs be helpful?

nd avatar May 13 '20 09:05 nd

That error is actually very different, it's coming from a different backend. We should use a different issue for this.

  1. is this error systematic or sporadic?
  2. I've never seen it locally or on Travis-CI so it must be something influenced by kernel version or virtualization environment
  3. The code that's producing that error is pkg/proc/native/threads_linux_amd64.go, the first step would be to decorate restoreRegistersErr to figure out which of the three syscalls is returning EFAULT.

Looking at that function and its sister ptraceGetRegset (in ptrace_linux_amd64.go) I would guess that it's PTRACE_SETFPREGS, but it would be a systematic error, not something that happens once in a while.

aarzilli avatar May 13 '20 09:05 aarzilli

Thanks will file a dedicated issue. The error seems to be sporadic and so far I've seen it only on virtual machines.

nd avatar May 13 '20 12:05 nd