You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "qwzhou89 (via GitHub)" <gi...@apache.org> on 2023/07/21 07:12:46 UTC
[GitHub] [apisix] qwzhou89 opened a new issue, #9878: bug: a error "changing jit stack size is not allowed when some regexs have already been compiled and cached" is output
qwzhou89 opened a new issue, #9878:
URL: https://github.com/apache/apisix/issues/9878
### Current Behavior
When I put the code to register a new variable inside my_hook.lua and execute apisix reload, an error is output inside the logs
### Expected Behavior
There should be no mistakes.
### Error Logs
2023/07/21 06:53:10 [error] 1#1: init_by_lua error: /usr/local/apisix/apisix/init.lua:21: changing jit stack size is not allowed when some regexs have already been compiled and cached
stack traceback:
[C]: in function 'error'
/usr/local/openresty/lualib/ngx/re.lua:297: in function 'opt'
/usr/local/apisix/apisix/init.lua:21: in main chunk
[C]: in function 'require'
init_by_lua:4: in main chunk
### Steps to Reproduce
1.Run APISIX 2.15.3 in docker.
2.Modify 3 of the lines in conf/config-default.yaml as follows:
```shell
extra_lua_path: "/usr/local/apisix/conf/hook/?.lua" # extend lua_package_path to load third party code
extra_lua_cpath: "" # extend lua_package_cpath to load third party code
lua_module_hook: "my_hook" # the hook module which will be used to inject third party code into APISIX
```
3.Create a new /usr/local/apisix/conf/hook/my_hook.lua file and insert the following contents
(this is copied from https://apisix.apache.org/docs/apisix/next/plugin-develop/#register-custom-variable)
```lua
local core = require "apisix.core"
core.ctx.register_var("a6_labels_zone", function(ctx)
local route = ctx.matched_route and ctx.matched_route.value
if route and route.labels then
return route.labels.zone
end
return nil
end)
```
4.Execute the `apisix reload` command
5.In the log there is the following output
```
2023/07/21 07:11:38 [warn] 1#1: "ssl_stapling" ignored, issuer certificate not found for certificate "/usr/local/apisix/conf/cert/ssl_PLACE_HOLDER.crt"
2023/07/21 07:11:38 [error] 1#1: init_by_lua error: /usr/local/apisix/apisix/init.lua:21: changing jit stack size is not allowed when some regexs have already been compiled and cached
stack traceback:
[C]: in function 'error'
/usr/local/openresty/lualib/ngx/re.lua:297: in function 'opt'
/usr/local/apisix/apisix/init.lua:21: in main chunk
[C]: in function 'require'
init_by_lua:4: in main chunk
```
### Environment
- APISIX version (run `apisix version`):2.15.3
- Operating system (run `uname -a`):Linux k8s-m-3 4.19.225-0419225-generic #202201110859 SMP Tue Jan 11 14:15:40 UTC 2022 x86_64 GNU/Linux
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
- etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`):
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
--
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-unsubscribe@apisix.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] qwzhou89 commented on issue #9878: bug: a error "changing jit stack size is not allowed when some regexs have already been compiled and cached" is output
Posted by "qwzhou89 (via GitHub)" <gi...@apache.org>.
qwzhou89 commented on issue #9878:
URL: https://github.com/apache/apisix/issues/9878#issuecomment-1647115449
> This is not the correct way to register variables in APISIX. You can create a new file under `apisix/plugins` and then enlist the name of the plugins in the plugins list in `config.yaml`.
This error has no relationship with register variables. For example, if I write just one line of code in conf/hook/my_hook.lua.
```lua
local apisix_upstream = require("apisix.upstream")
```
and then `apisix reload` it, it also gives me the error
```
2023/07/24 02:33:11 [error] 1#1: init_by_lua error: /usr/local/apisix/apisix/init.lua:21: changing jit stack size is not allowed when some regexs have already been compiled and cached
stack traceback:
[C]: in function 'error'
/usr/local/openresty/lualib/ngx/re.lua:297: in function 'opt'
/usr/local/apisix/apisix/init.lua:21: in main chunk
[C]: in function 'require'
init_by_lua:4: in main chunk
```
It seems that only `local apisix = require("apisix")` doesn't make mistakes
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] shreemaan-abhishek commented on issue #9878: bug: a error "changing jit stack size is not allowed when some regexs have already been compiled and cached" is output
Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on issue #9878:
URL: https://github.com/apache/apisix/issues/9878#issuecomment-1646785625
This is not the correct way to register variables in APISIX. You can create a new file under `apisix/plugins` and then enlist the name of the plugins in the plugins list in `config.yaml`.
https://github.com/shreemaan-abhishek/apisix/blob/59c1d99a6a571a77d9c3f7995a23785d93a4a92c/conf/config-default.yaml#L432
Now if you use that plugin your variable will be registered.
Or you can simply register variables using the serverless functions like so:
```bash
curl http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/test",
"plugins": {
"serverless-pre-function": {
"phase": "rewrite",
"functions" : ["return function() require(\"apisix.core\").ctx.register_var(\"lol\", function(ctx) return string.gsub(ngx.var.request_uri, \"?.*\", \"\"); end)
; end"] <<<< registering the variable
},
"response-rewrite": {
"headers": {
"set": {
"X-Lol": "$lol" <<<< using the variable
}
}
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:1980": 1
}
}
}'
```
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] gy8409 commented on issue #9878: bug: a error "changing jit stack size is not allowed when some regexs have already been compiled and cached" is output
Posted by "gy8409 (via GitHub)" <gi...@apache.org>.
gy8409 commented on issue #9878:
URL: https://github.com/apache/apisix/issues/9878#issuecomment-1727328727
Have you resolve this issue? Or do you have any work around? I met the same problem when I tried to add lua hook code to debug.
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] moonming closed issue #9878: bug: a error "changing jit stack size is not allowed when some regexs have already been compiled and cached" is output
Posted by "moonming (via GitHub)" <gi...@apache.org>.
moonming closed issue #9878: bug: a error "changing jit stack size is not allowed when some regexs have already been compiled and cached" is output
URL: https://github.com/apache/apisix/issues/9878
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Revolyssup commented on issue #9878: bug: a error "changing jit stack size is not allowed when some regexs have already been compiled and cached" is output
Posted by "Revolyssup (via GitHub)" <gi...@apache.org>.
Revolyssup commented on issue #9878:
URL: https://github.com/apache/apisix/issues/9878#issuecomment-1647325445
> > This is not the correct way to register variables in APISIX. You can create a new file under `apisix/plugins` and then enlist the name of the plugins in the plugins list in `config.yaml`.
>
> This error has no relationship with register variables. For example, if I write just one line of code in conf/hook/my_hook.lua.
>
> ```lua
> local apisix_upstream = require("apisix.upstream")
> ```
>
> and then `apisix reload` it, it also gives me the error
>
> ```
> 2023/07/24 02:33:11 [error] 1#1: init_by_lua error: /usr/local/apisix/apisix/init.lua:21: changing jit stack size is not allowed when some regexs have already been compiled and cached
> stack traceback:
> [C]: in function 'error'
> /usr/local/openresty/lualib/ngx/re.lua:297: in function 'opt'
> /usr/local/apisix/apisix/init.lua:21: in main chunk
> [C]: in function 'require'
> init_by_lua:4: in main chunk
> ```
>
> It seems that only `local apisix = require("apisix")` doesn't make mistakes
The PCRE JIT stack is loaded when apisix module is loaded. The debug hook is executed after every 1 second so it will try to load apisix module again and again, which will give error. As @shreemaan-abhishek Pointed out above, this is not the correct way to register variable. Use something like the serverless plugin.
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] qwzhou89 commented on issue #9878: bug: a error "changing jit stack size is not allowed when some regexs have already been compiled and cached" is output
Posted by "qwzhou89 (via GitHub)" <gi...@apache.org>.
qwzhou89 commented on issue #9878:
URL: https://github.com/apache/apisix/issues/9878#issuecomment-1654884875
> As @shreemaan-abhishek Pointed out above, this is not the correct way to register variable. Use something like the serverless plugin.
实际上我不是想要去自定义变量。
就像
https://apisix.apache.org/zh/docs/apisix/2.15/plugin-develop/#%E6%8F%92%E4%BB%B6%E6%94%BE%E7%BD%AE%E8%B7%AF%E5%BE%84
里说的
> 可能你会想覆盖一个文件中的函数,你可以在 conf/config.yaml 文件中配置 lua_module_hook 来使你的 hook 生效。
> 你的配置可以像下面这样:
> ```yaml
> apisix:
> ...
> extra_lua_path: "/path/to/example/?.lua"
> lua_module_hook: "my_hook"
> ```
我想去覆盖某个模块里面的一个函数。但是当我在my_hook写代码去`require`这个模块的时候,就会报错。
```
2023/07/28 02:28:12 [error] 1#1: init_by_lua error: /usr/local/apisix/apisix/init.lua:21: changing jit stack size is not allowed when some regexs have already been compiled and cached
stack traceback:
[C]: in function 'error'
/usr/local/openresty/lualib/ngx/re.lua:297: in function 'opt'
/usr/local/apisix/apisix/init.lua:21: in main chunk
[C]: in function 'require'
init_by_lua:4: in main chunk
```
只有`require("apisix")`的时候不报错。这应该是有问题的。
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org