10000 Memory leak on shutdown due to missing free for init_cycle.pool · Issue #742 · nginx/nginx · GitHub
[go: up one dir, main page]

Skip to content
Memory leak on shutdown due to missing free for init_cycle.pool #742
@tteokbokki-master

Description

@tteokbokki-master

Environment

Include the result of the following commands:

  • nginx -V
nginx version: nginx/1.29.0
built by gcc 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)
  • uname -a
Linux whs-1-01 5.15.0-101-generic #111-Ubuntu SMP Tue Mar 5 20:16:58 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Description

In the main() function of src/core/nginx.c, the init_cycle.pool allocation is not freed on either normal shutdown or error exit, resulting in a memory leak when nginx terminates. All dynamically allocated memory should be properly released on shutdown, but in the current implementation, this allocation is omitted, causing it to remain allocated after exit. This issue is reproducible on the latest version of nginx (1.29.0) with a minimal configuration and without any third-party modules.

  • The bug is reproducible with the latest version of nginx
  • The nginx configuration is minimized to the smallest possible
    to reproduce the issue and doesn't contain third-party modules

nginx configuration

Configuration not relevant to the issue.
Default minimal configuration used for startup and shutdown only.

nginx debug log

Since the issue occurs during shutdown and is memory-related (not runtime behavior), valgrind was used to validate the leak instead of debug logging.

==272264== 1,024 bytes in 1 blocks are definitely lost in loss record 4 of 5
==272264==    at 0x484DE30: memalign (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==272264==    by 0x484DF92: posix_memalign (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==272264==    by 0x1470EF: ngx_memalign (ngx_alloc.c:57)
==272264==    by 0x1253B6: ngx_create_pool (ngx_palloc.c:23)
==272264==    by 0x123BE2: main (nginx.c:254)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0