mirror of
				https://github.com/go-delve/delve.git
				synced 2025-10-31 10:47:27 +08:00 
			
		
		
		
	proc_test: deflake TestSystemstackOnRuntimeNewstack (#1078)
Depending on how the runtime schedules our goroutines we can get unlucky and have the first call to runtime.newstack we intercept be for a different goroutine (usually the garbage collector). Only check stacktraces that happen on the same goroutine that executed main.main.
This commit is contained in:
		 Alessandro Arzilli
					Alessandro Arzilli
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							3f3de1a9b5
						
					
				
				
					commit
					bc77ff4534
				
			| @ -3365,11 +3365,21 @@ func TestSystemstackOnRuntimeNewstack(t *testing.T) { | ||||
| 		_, err := setFunctionBreakpoint(p, "main.main") | ||||
| 		assertNoError(err, t, "setFunctionBreakpoint(main.main)") | ||||
| 		assertNoError(proc.Continue(p), t, "first continue") | ||||
| 		_, err = setFunctionBreakpoint(p, "runtime.newstack") | ||||
| 		assertNoError(err, t, "setFunctionBreakpoint(runtime.newstack)") | ||||
| 		assertNoError(proc.Continue(p), t, "second continue") | ||||
|  | ||||
| 		g, err := proc.GetG(p.CurrentThread()) | ||||
| 		assertNoError(err, t, "GetG") | ||||
| 		mainGoroutineID := g.ID | ||||
|  | ||||
| 		_, err = setFunctionBreakpoint(p, "runtime.newstack") | ||||
| 		assertNoError(err, t, "setFunctionBreakpoint(runtime.newstack)") | ||||
| 		for { | ||||
| 			assertNoError(proc.Continue(p), t, "second continue") | ||||
| 			g, err = proc.GetG(p.CurrentThread()) | ||||
| 			assertNoError(err, t, "GetG") | ||||
| 			if g.ID == mainGoroutineID { | ||||
| 				break | ||||
| 			} | ||||
| 		} | ||||
| 		frames, err := g.Stacktrace(100) | ||||
| 		assertNoError(err, t, "stacktrace") | ||||
| 		logStacktrace(t, frames) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user