phpcyy opened a new issue, #3190:
URL: https://github.com/apache/dubbo-go/issues/3190
### Summary
In v3.3.1, BaseInvoker.Destroy() sets url to nil. If an invoker is destroyed
while a request is still in-flight, filter OnResponse may still call
invoker.GetURL() and dereference it, leading to a nil pointer panic.
### Environment
- Version: v3.3.1
- Component: protocol/base + filter chain
### Repro (v3.3.1)
1. Checkout tag v3.3.1
2. Add a temporary test file `filter/active/filter_destroy_test.go` with the
following content (this file is only for reproducing the issue):
```go
package active
import (
"context"
"fmt"
"strconv"
"testing"
"dubbo.apache.org/dubbo-go/v3/common"
"dubbo.apache.org/dubbo-go/v3/common/constant"
"dubbo.apache.org/dubbo-go/v3/protocol/base"
"dubbo.apache.org/dubbo-go/v3/protocol/invocation"
"dubbo.apache.org/dubbo-go/v3/protocol/result"
)
type destroyOnInvokeInvoker struct {
*base.BaseInvoker
}
func (d *destroyOnInvokeInvoker) Invoke(_ context.Context, _
base.Invocation) result.Result {
// simulate an invoker being destroyed while a request is in-flight
d.Destroy()
return &result.RPCResult{}
}
func TestActiveFilterOnResponseWithDestroyedInvoker(t *testing.T) {
invoc := invocation.NewRPCInvocation("test", []any{"OK"}, map[string]any{
dubboInvokeStartTime: strconv.FormatInt(base.CurrentTimeMillis(),
10),
})
url, _ :=
common.NewURL(fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider",
constant.LocalHostValue, constant.DefaultPort))
invoker := &destroyOnInvokeInvoker{BaseInvoker: base.NewBaseInvoker(url)}
filter := activeFilter{}
res := filter.Invoke(context.Background(), invoker, invoc)
filter.OnResponse(context.Background(), res, invoker, invoc)
}
```
3. Run:
`go test ./filter/active -run
TestActiveFilterOnResponseWithDestroyedInvoker`
### Actual
Panic occurs: nil pointer dereference in filter OnResponse path
(invoker.GetURL() -> url.Key()).
### Expected
In-flight requests should not panic if the invoker is destroyed; either keep
URL available or guard against nil.
### Notes
This is a timing issue that can occur under registry-driven invoker removal
(e.g. Nacos notify + directory refresh).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]