Opened 2 years ago

Closed 2 years ago

#2288 closed defect (invalid)

log safely while configuration reloading

Reported by: al.drozdov@… Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.19.x
Keywords: Cc: al.drozdov@…
uname -a: Linux sw 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.21.1
configure arguments: --with-debug --add-module=../lua-nginx-module

Description

We implemented a custom feature that uses shared memory by ngx_log_t objects (we haven't published it yet).

The feature doesn't work correctly as nginx may use partially freed log objects while reloading: ngx_init_cycle() frees shared memory of the old cycle but ngx_log_t objects of the old cycle still may be used.

I'll attach a patch fixes that.

Attachments (1)

fix-core-on-reloading.patch (1.5 KB ) - added by al.drozdov@… 2 years ago.
A patch fixes the bug

Download all attachments as: .zip

Change History (2)

by al.drozdov@…, 2 years ago

Attachment: fix-core-on-reloading.patch added

A patch fixes the bug

comment:1 by Maxim Dounin, 2 years ago

Resolution: invalid
Status: newclosed

This looks a problem in your custom code rather than in nginx.

Further, the patch looks wrong to me, as it tries to overwrite some known log objects with unrelated log objects from the new cycle: this is both wrong (as cleanup is expected to use log objects from the old cycle) and insufficient (as there might be other references to old cycle log objects, such as in resolver or at different configuration levels).

If you think the problem in your code cannot be resolved without changing nginx code, you may want to discuss this and suggest improvements in the nginx-devel@ mailing list, as recommended here.

Note: See TracTickets for help on using tickets.