Details
-
Bug
-
Resolution: Fixed
-
Major
-
7.6.0
-
Untriaged
-
0
-
Unknown
Description
Panic can occur when UDF is executed in the projection.
1. Set logLevel to DEBUG:
curl http://localhost:8093/admin/settings -u Administrator:password -H 'Content-Type: application/json' -d '{"logLevel": "DEBUG"}' |
2. Create a UDF
3. Execute these queries:
SELECT inline1();
or
SELECT * FROM kids ORDER BY inline1();
A panic is seen in query.log
This occurs because of - https://github.com/couchbase/query/blob/ae9ab2ad134d2014ace3551238b5158d1a614dca/expression/func_user_defined.go#L71
We need to handle the case of the Context object being nil or when the interface conversion to ParkableContext fails.
2023-12-01T17:04:37.389+05:30 [DEBUG] Panic during evaluation: interface conversion: interface is nil, not expression.ParkableContext |
2023-12-01T17:04:37.389+05:30 [DEBUG] goroutine 613 [running]: |
github.com/couchbase/query/logging.Stackf(0x7, {0x101d43774, 0x1b}, {0xc000f51e50, 0x1, 0x1}) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/logging/logger.go:497 +0x9c |
github.com/couchbase/query/expression.(*ExpressionBase).Value.func1()
|
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/expression/base.go:212 +0xc6 |
panic({0x1019da5a0, 0xc0017baf60}) |
/usr/local/Cellar/go/1.19.5/libexec/src/runtime/panic.go:884 +0x212 |
github.com/couchbase/query/expression.(*UserDefinedFunction).Evaluate(0xc000f6b500, {0x0, 0x0}, {0x0?, 0x0}) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/expression/func_user_defined.go:83 +0x13d |
github.com/couchbase/query/expression.(*ExpressionBase).Value(0xc000f6b500) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/expression/base.go:216 +0x1a3 |
github.com/couchbase/query/expression.(*ExpressionBase).valueEquivalentTo(0x1008475af?, {0x10261e088, 0xc0004b2700}) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/expression/base.go:432 +0x2e |
github.com/couchbase/query/expression.(*ExpressionBase).EquivalentTo(0xc000f6b500, {0x10261e088, 0xc0004b2700}) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/expression/base.go:307 +0x2f |
github.com/couchbase/query/expression.(*FunctionBase).EquivalentTo(0x100848219?, {0x10261e088?, 0xc0004b2700?}) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/expression/function.go:153 +0x31 |
github.com/couchbase/query/algebra.NewResultTerm({0x102620c18, 0xc000f6b500}, 0x0, {0x0, 0x0}) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/algebra/result.go:338 +0x76 |
github.com/couchbase/query/parser/n1ql.(*yyParserImpl).Parse(0xc0017e2000, {0x1025d06a8?, 0xc0017de000?}) |
n1ql.y:1213 +0x415d |
github.com/couchbase/query/parser/n1ql.yyParse(...)
|
yaccpar:153 |
github.com/couchbase/query/parser/n1ql.doParse(0xc0017de000?) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/parser/n1ql/n1ql.go:124 +0x7f |
github.com/couchbase/query/parser/n1ql.parseStatement({0xc0017a6ca0?, 0x10005fe5f?}, {0x101d1536c, 0x7}, {0xc000f545a0, 0x16}, 0x1, {0x1025f3758, 0xc0017da000}) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/parser/n1ql/n1ql.go:57 +0x2f9 |
github.com/couchbase/query/parser/n1ql.ParseStatement2({0xc0017a6ca0?, 0x100010d064fff?}, {0x101d1536c?, 0x100049925?}, {0xc000f545a0?, 0xc0018df318?}, {0xc0018df510?, 0x1000195c6?, 0x10cf23d00?}) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/parser/n1ql/n1ql.go:41 +0x4f |
github.com/couchbase/query/server.(*Server).getPrepared(0xc001098000, {0x1026867a0, 0xc00083a600}, 0xc0017da000) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/server/server.go:1463 +0x9cf |
github.com/couchbase/query/server.(*Server).serviceRequest(0xc001098000, {0x1026867a0, 0xc00083a600}) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/server/server.go:1305 +0x4d4 |
github.com/couchbase/query/server.(*Server).handleRequest(0xc001098000?, {0x1026867a0, 0xc00083a600}, 0xc0018df800?) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/server/server.go:831 +0x145 |
github.com/couchbase/query/server.(*Server).ServiceRequest(0xc001098000, {0x1026867a0, 0xc00083a600}) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/server/server.go:744 +0x4c |
github.com/couchbase/query/server/http.(*HttpEndpoint).ServeHTTP(0xc000183520, {0x1025d51b0, 0xc0017b0460}, 0xc0017d4000) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/server/http/service_endpoint.go:393 +0xa5c |
github.com/couchbase/query/server/http/router.(*routerImpl).ServeHTTP(0xc000113680, {0x1025d51b0, 0xc0017b0460}, 0xc000f6ff00) |
/Users/dhanyagowrish/Dhanya/DhanyaQ/src/github.com/couchbase/query/server/http/router/router.go:217 +0x208 |
net/http.serverHandler.ServeHTTP({0x1025d1e90?}, {0x1025d51b0, 0xc0017b0460}, 0xc000f6ff00) |
/usr/local/Cellar/go/1.19.5/libexec/src/net/http/server.go:2947 +0x30c |
net/http.(*conn).serve(0xc000985cc0, {0x1025dcc28, 0xc00140d410}) |
/usr/local/Cellar/go/1.19.5/libexec/src/net/http/server.go:1991 +0x607 |
created by net/http.(*Server).Serve
|
/usr/local/Cellar/go/1.19.5/libexec/src/net/http/server.go:3102 +0x4db |