zJiaJun opened a new issue, #13188:
URL: https://github.com/apache/skywalking/issues/13188

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Apache SkyWalking Component
   
   Go Agent (apache/skywalking-go)
   
   ### What happened
   
   In skywalking-go v0.5.0, the runtime instrumentation logic for Go versions 
1.23 and later appears to be incomplete. Specifically, the check for the number 
of parameters in the internal runtime.newproc1 function is incorrect, causing 
the automatic context propagation logic for new goroutines to be skipped during 
instrumentation.
   Details:
   Agent Version: apache/skywalking-go v0.5.0 (which claims support for Go 1.23 
via PR #192)
   Go Version: Tested on Go 1.24.2 (issue applies to Go 1.23+)
   File: tools/go-agent/instrument/runtime/instrument.go
   Function: FilterAndEdit method of the runtime.Instrument struct.
   Problem: When processing the AST for the runtime.newproc1 function, the code 
explicitly checks if len(n.Type.Params.List) != 3.
   Discrepancy: As confirmed by Go source code 1, newproc1 in Go 1.23 and later 
versions actually has 5 parameters.
   Consequence: Because 5 != 3, the check evaluates to true, causing the 
FilterAndEdit function to return false immediately for the newproc1 node.
   Impact: This prevents the subsequent call to tools.InsertStmtsBeforeBody 
from executing. This specific call is responsible for injecting the defer 
statement that handles automatic context propagation when a new goroutine is 
created via newproc1.
   Observation: Debugging confirms that this check fails for the 5-parameter 
newproc1 AST node and the injection code is skipped. While PR #192 addressed 
other Go 1.23 compatibility issues (like internal/atomic path), it did not 
modify this specific parameter check.
   
   ### What you expected to happen
   
   When using skywalking-go agent v0.5.0 with Go 1.23 or Go 1.24, the runtime 
instrumentation (tools/go-agent/instrument/runtime/instrument.go) should 
correctly identify the runtime.newproc1 function, regardless of its parameter 
count (which is 5 in these Go versions).
   Consequently, the agent should successfully inject the defer statement into 
newproc1's body. This injected code is crucial for automatically propagating 
the SkyWalking tracing context when new goroutines are created.
   The expected outcome is seamless, automatic context propagation across 
goroutines initiated via the standard go keyword, without requiring manual 
context handling in user code for this specific scenario.
   
   ### How to reproduce
   
   Environment:
   Go version: 1.23.x or 1.24.x (e.g., 1.24.2)
   skywalking-go agent: v0.5.0 (built from source or downloaded binary)
   Operating System: Any (e.g., macOS arm64, Linux amd64)
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request to fix on your own?
   
   - [x] Yes I am willing to submit a pull request on my own!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: 
notifications-unsubscr...@skywalking.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to