From 84e4a6437f69b14b1cafbe7915447fdcf1d87f68 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Wed, 18 Sep 2019 18:31:14 +0300 Subject: Go: do not store pointer to Go object. To pass Go object references to C and back we use hack with casting to unsafe and then to uintptr. However, we should not store such references because Go not guaratnee it will be available by the same address. Introducing map with integer key helps to avoid dereference stored address. This closes #253 and #309 issues on GitHub. --- src/go/unit/request.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/go/unit/request.go') diff --git a/src/go/unit/request.go b/src/go/unit/request.go index ad56cabb..1d8c6702 100644 --- a/src/go/unit/request.go +++ b/src/go/unit/request.go @@ -135,7 +135,7 @@ func nxt_go_request_set_tls(go_req uintptr) { //export nxt_go_request_handler func nxt_go_request_handler(go_req uintptr, h uintptr) { r := get_request(go_req) - handler := *(*http.Handler)(unsafe.Pointer(h)) + handler := get_handler(h) go func(r *request) { handler.ServeHTTP(r.response(), &r.req) -- cgit