nginx / unit

NGINX Unit - universal web app server - a lightweight and versatile open source server that simplifies the application stack by natively executing application code across eight different programming language runtimes.
https://unit.nginx.org
Apache License 2.0
5.38k stars 324 forks source link

Error apply configuration with use jemalloc memory allocator and glibc 2.34 #672

Open Izorkin opened 2 years ago

Izorkin commented 2 years ago

Error apply configuration with use jemalloc memory allocator and glibc 2.34. Testing on Ubuntu 21.10 and NixOS Unstable.

Steps To Reproduce

  1. Install jemmalloc
    apt install libjemalloc2
  2. Create file `/etc/ld.so.preload:
    /usr/lib/x86_64-linux-gnu/libjemalloc.so.2
  3. Restart unit:
    systemctl restart unit
  4. Write configuration config.json:
    {
    "type": "php",
    "root": "/www/blogs/scripts"
    }
  5. Apply configuration:
    mkdir -p /www/blogs/scripts
    curl -X PUT --data-binary @config.json --unix-socket /var/run/control.unit.sock http://localhost/config/applications/blogs

Error:

{
        "error": "Failed to apply new configuration."
}

Debug log: unit-debug.log

OS: Ubuntu 21.10 Unit: 1.26.1 glibc: 2.34

This error also occurs on NixOS after updating glibc from version 2.33 to 2.34 - https://github.com/NixOS/nixpkgs/issues/167666

tippexs commented 2 years ago

Thanks for reaching out. From the debug log it looks like there is a problem with a pointer in the PHP Lang module. Could you try to use Unit with a minimal configuration:

{
    "listeners": {
        "127.0.0.1:8080": {
            "pass": "routes"
        }
    },
    "routes": [
        {
            "action": {
                "return": 204
            }
        }
    ]
}

This configuration will not call any application modules. That will help to locate the issue.

Izorkin commented 2 years ago

This config applied:

{
        "success": "Reconfiguration done."
}
ac000 commented 2 years ago

I also see the same thing by simply doing (on Fedora 35, jemalloc 5.2.1, php 8.0.18)

$ LD_PRELOAD=/lib64/libjemalloc.so.2 php
free(): invalid pointer
Aborted (core dumped)