NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.43k stars 13.64k forks source link

Error start nginx unit with use jemalloc memory allocator and glibc 2.34 #167666

Closed Izorkin closed 11 months ago

Izorkin commented 2 years ago

Describe the bug

Error start nginx unit with use jemalloc memory allocator and glibc 2.34

Steps To Reproduce

Steps to reproduce the behavior:

  1. Apply patch:

    
    diff --git a/nixos/tests/web-servers/unit-php.nix b/nixos/tests/web-servers/unit-php.nix
    index 5bef7fab3ef..db28b7ef86b 100644
    --- a/nixos/tests/web-servers/unit-php.nix
    +++ b/nixos/tests/web-servers/unit-php.nix
    @@ -7,6 +7,7 @@ in {
    meta.maintainers = with pkgs.lib.maintainers; [ izorkin ];
    
    nodes.machine = { config, lib, pkgs, ... }: {
    +    systemd.services.unit.environment = { LD_PRELOAD = "${pkgs.jemalloc}/lib/libjemalloc.so"; };
     services.unit = {
       enable = true;
       config = pkgs.lib.strings.toJSON {
2. Run `nix-build nixos/tests/web-servers/unit-php.nix`

Error:

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

Debug log:

[debug] 71678#71678 "php-74-info" prototype setup [debug] 71678#71678 setproctitle: "unit: "php-74-info" prototype" [debug] 71678#71678 epoll 3 free [debug] 71678#71678 free(618738078000) [debug] 71678#71678 free(618738073000) [debug] 71678#71678 malloc(2048): 618738073000 [debug] 71678#71678 malloc(384): 618738078000 [debug] 71678#71678 epoll_create(): 3 [debug] 71678#71678 signalfd(): 4 [debug] 71678#71678 eventfd(): 5 [debug] 71678#71678 malloc(232): 61873807B000 [debug] 71678#71678 socket close(8) [debug] 71678#71678 pthread_mutex_lock(61873805C078) enter [debug] 71678#71678 process 71678 added [debug] 71678#71678 pthread_mutex_unlock(61873805C078) exit [debug] 71678#71678 epoll 3 set event: fd:10 op:1 ev:80002001 [debug] 71678#71678 application language module: 7.4.28 "/nix/store/84gi28nnmwrsgnf5yggzqc4cgw5x6shk-unit-1.26.1/modules/php74.unit.so" [debug] 71678#71678 malloc(20): 6187380252C0 free(): invalid pointer [debug] 71125#71125 epoll_wait(3): 1 [debug] 71125#71125 epoll: fd:4 ev:0001 d:61873803C6A8 rd:0 wr:0 [debug] 71125#71125 timer expire minimum: 127507165:41107558 [debug] 71125#71125 work queue: fast [debug] 71125#71125 signalfd handler [debug] 71125#71125 read signalfd(4): 128 [debug] 71125#71125 signalfd(4) signo:17 [debug] 71125#71125 sigchld handler signo:17 (SIGCHLD) [debug] 71125#71125 waitpid(): 71678 [alert] 71125#71125 process 71678 exited on signal 6 (core dumped)



### Notify maintainers
cc @Ma27 @jonringer
PedroHLC commented 2 years ago

I tried using jemalloc globally (environment.memoryAllocator.provider = "jemalloc";) and noted some apps fail. Debugging them showed to be free-related.

To be more specific: Spotify and Discord crashed on start, Firefox when exiting, and TabNine would freeze. One can have the same "fun" with LD_PRELOAD=/nix/store/${jemalloc}/lib/libjemalloc.so spotify.

Looking positively, a lot of stuff seems to work...

PS: I did not have the guts to test https://github.com/NixOS/nixpkgs/pull/171859.

SuperSandro2000 commented 11 months ago

Going to close this as it does not seem this is supported by upstream and there is no immediate actions for us possible.