openresty / openresty/lua-nginx-module
Maybe it's a bug about the ngx_http_lua_init_worker function.
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
In the ngx_http_lua_init_worker function, use the http_ctx.main_conf = cycle->conf_ctx->main_conf to initialize. However, the value of main_conf may be modified in the later by merge_srv_conf or merge_loc_conf functions, which may cause some unexpected problems.
Forexample ngx_http_charset_merge_loc_conf function will be modify the value of mcf->recodes.
static char *
ngx_http_charset_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
{
ngx_http_charset_loc_conf_t *prev = parent;
ngx_http_charset_loc_conf_t *conf = child;
ngx_uint_t i;
ngx_http_charset_recode_t *recode;
ngx_http_charset_main_conf_t *mcf;
if (ngx_http_merge_types(cf, &conf->types_keys, &conf->types,
&prev->types_keys, &prev->types,
ngx_http_charset_default_types)
!= NGX_OK)
{
return NGX_CONF_ERROR;
}
ngx_conf_merge_value(conf->override_charset, prev->override_charset, 0);
ngx_conf_merge_value(conf->charset, prev->charset, NGX_HTTP_CHARSET_OFF);
ngx_conf_merge_value(conf->source_charset, prev->source_charset,
NGX_HTTP_CHARSET_OFF);
if (conf->charset == NGX_HTTP_CHARSET_OFF
|| conf->source_charset == NGX_HTTP_CHARSET_OFF
|| conf->charset == conf->source_charset)
{
return NGX_CONF_OK;
}
if (conf->source_charset >= NGX_HTTP_CHARSET_VAR
|| conf->charset >= NGX_HTTP_CHARSET_VAR)
{
return NGX_CONF_OK;
}
mcf = ngx_http_conf_get_module_main_conf(cf,
ngx_http_charset_filter_module);
recode = mcf->recodes.elts;
for (i = 0; i < mcf->recodes.nelts; i++) {
if (conf->source_charset == recode[i].src
&& conf->charset == recode[i].dst)
{
return NGX_CONF_OK;
}
}
recode = ngx_array_push(&mcf->recodes);
if (recode == NULL) {
return NGX_CONF_ERROR;
}
recode->src = conf->source_charset;
recode->dst = conf->charset;
return NGX_CONF_OK;
}
So we should create of our own http_ctx.main_conf instead of directly reusing the current http_ctx.main_conf. Maybe it's fixed by PR , Plz check.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/ngx_http_lua_initworkerby.c and trace how ngx_http_lua_init_worker uses http_ctx.main_conf before merge_srv_conf and merge_loc_conf run. Compare this behavior with ngx_http_charset_merge_loc_conf in nginx's ngx_http_charset_filter_module.c and inspect the referenced commit. Done means determining whether the shared main configuration can be changed unexpectedly and whether the referenced commit resolves it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, lua, nginx
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100