Bug#1116033: nexuiz: Lots of memory is allocated whenever video settings apply button is clicked

Bernhard Übelacker bernhardu at mailbox.org
Sun Oct 19 20:35:07 BST 2025


Control: reassign -1 darkplaces 0~20180908~beta1-6
Control: affects -1 nexuiz


On Tue, 23 Sep 2025 14:46:55 +0200 =?utf-8?q?=C3=86lla_Chiana_Arson_Bobbie_Moskopp?= <acab+debian-reportbug at dieweltistgarnichtso.net> wrote:> Package: nexuiz

> Dear Maintainer,
> 
> whenever I click the “Apply immediately” button in Nexuiz in the
> video settings dialog, the program allocates more memory even if
> nothing changed in the settings. I expected it to not allocate a
> single bit more than it had allocated previously.
> 
> Depending on if a level is loaded and which settings are active,
> the amount of memory in these allocations can be hundreds of MB.
> 
> I only came upon this because my system hung after I changed the
> settings a few times to see which ones yield the best experience
> (i.e. look good, while not leading to an unplayable frame rate).
> 
> -- System Information:
> Debian Release: forky/sid
>   APT prefers unstable
>   APT policy: (500, 'unstable')
> Architecture: arm64 (aarch64)



Hello,
I could also see an increased memory usage with using "Apply immediately".
This was observable with a aarch64 qemu VM, but also with x86_64 qemu VM.
(both using virtio-gpu-gl-pci or virtio-vga-gl)

With x86_64 I could track down part of it to following upstream commit,
which seems also applicable to current version of darkplaces in debian.

     https://github.com/DarkPlacesEngine/DarkPlaces/commit/72d993ebe1069e0813747379d0878d5c335f6b08.patch


Without it ASan reported this summary after 10 times "Apply immediately":
     SUMMARY: AddressSanitizer: 19110630 byte(s) leaked in 109361 allocation(s).

With this patch applied ASan reported this summary after 10 times "Apply immediately":
     SUMMARY: AddressSanitizer: 9952184 byte(s) leaked in 3306 allocation(s).


So this may be an improvement, but other reported allocations originate
somewhere in the display driver, which did not reveal a simple solution to me.

Because this got reported for aarch64 there may be architecture/driver dependent leaks,
which do not show up in my VMs. Also tested here just with Xorg.

Attached file contains some details how I got this results.


Reassigning to darkplaces package like justified in bug #1116031.

Kind regards,
Bernhard
-------------- next part --------------

root at debian:~# free -h
              gesamt       benutzt     frei      gemns.  Puffer/Cache verfügbar
Speicher:      2,8Gi       749Mi       1,3Gi       196Mi       1,1Gi       2,1Gi
Swap:          975Mi          0B       975Mi

root at debian:~# ps aux | grep -E "USER|dark" | grep -v "grep -"
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
benutzer     989 84.1  5.4 591584 161036 pts/0   RLl+ 16:56   0:37 /usr/games/darkplaces -nexuiz -basedir /usr/share/games/nexuiz
root at debian:~# ps aux | grep -E "USER|dark" | grep -v "grep -"
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
benutzer     989 82.9  5.6 604784 167536 pts/0   RLl+ 16:56   0:45 /usr/games/darkplaces -nexuiz -basedir /usr/share/games/nexuiz
root at debian:~# ps aux | grep -E "USER|dark" | grep -v "grep -"
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
benutzer     989 82.5  5.8 618276 174372 pts/0   RLl+ 16:56   0:52 /usr/games/darkplaces -nexuiz -basedir /usr/share/games/nexuiz
root at debian:~# ps aux | grep -E "USER|dark" | grep -v "grep -"
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
benutzer     989 81.9  6.4 656812 192948 pts/0   RLl+ 16:56   1:04 /usr/games/darkplaces -nexuiz -basedir /usr/share/games/nexuiz
root at debian:~# ps aux | grep -E "USER|dark" | grep -v "grep -"
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
benutzer     989 81.3  6.7 669820 199304 pts/0   RLl+ 16:56   1:34 /usr/games/darkplaces -nexuiz -basedir /usr/share/games/nexuiz

--> also visible with x86_64, on each "Apply immediately" 0.2% MEM is more used.




# 2025-10-19 Trixie/stable amd64 qemu VM

apt install systemd-coredump xserver-xorg slim jwm xterm nexuiz htop btop tmux gdb mc quilt
apt build-dep darkplaces


mkdir /home/benutzer/source/darkplaces/orig -p
cd    /home/benutzer/source/darkplaces/orig
apt source darkplaces

mkdir /home/benutzer/source/mesa-libgallium/orig -p
cd    /home/benutzer/source/mesa-libgallium/orig
apt source mesa-libgallium




cd /home/benutzer/source/darkplaces
cp -a orig try1
cd try1/darkplaces-0~20180908~beta1

cd /home/benutzer/source/mesa-libgallium
cp -a orig try1
cd try1/darkplaces-0~20180908~beta1

export DEB_CFLAGS_APPEND=-fsanitize=address                       
export DEB_CPPFLAGS_APPEND=-fsanitize=address
export DEB_CXXFLAGS_APPEND=-fsanitize=address
export DEB_LDFLAGS_APPEND=-fsanitize=address
DEB_BUILD_OPTIONS="nostrip noopt" dpkg-buildpackage -b

cd /home/benutzer/source/darkplaces/try1
dpkg -i darkplaces_0~20180908~beta1-6_amd64.deb


export ASAN_OPTIONS="halt_on_error=0:log_exe_name=1:log_path=\"/home/benutzer/asan_\""
nexuiz

export ASAN_OPTIONS="halt_on_error=0:log_exe_name=1:log_path=\"/home/benutzer/asan_\":verify_asan_link_order=1"
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.8.0.0:/home/benutzer/source/mesa-libgallium/try1/mesa-25.0.7/build/src/gallium/targets/dri/libgallium-25.0.7-2.so:/home/benutzer/source/mesa-libgallium/try1/mesa-25.0.7/build/src/glx/libGLX_mesa.so /usr/games/darkplaces -nexuiz -basedir /usr/share/games/nexuiz





/home/benutzer/asan_.darkplaces.24433
...
Indirect leak of 163760 byte(s) in 5 object(s) allocated from:
    #0 0x7f74dfef4c57 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x7f74e24c5986 in ralloc_size ../src/util/ralloc.c:118
    #2 0x7f74e24c7fd0 in create_slab ../src/util/ralloc.c:826
    #3 0x7f74e24c820f in gc_alloc_size ../src/util/ralloc.c:865
    #4 0x7f74e24c8412 in gc_zalloc_size ../src/util/ralloc.c:893
    #5 0x7f74e25e0f02 in nir_intrinsic_instr_create ../src/compiler/nir/nir.c:745
    #6 0x7f74e1bc20e2 in _nir_build_store_output src/compiler/nir/nir_builder_opcodes.h:12820
    #7 0x7f74e1bc9d4c in emit_instructions ../src/mesa/main/ff_fragment_shader.c:918
    #8 0x7f74e1bca11b in create_new_program ../src/mesa/main/ff_fragment_shader.c:952
    #9 0x7f74e1bca756 in _mesa_get_fixed_func_fragment_program ../src/mesa/main/ff_fragment_shader.c:991
    #10 0x7f74e133c638 in update_program ../src/mesa/main/state.c:259
    #11 0x7f74e133dd6b in _mesa_update_state_locked ../src/mesa/main/state.c:568
    #12 0x7f74e133de5b in _mesa_update_state ../src/mesa/main/state.c:593
    #13 0x7f74e1d412fd in check_extra ../src/mesa/main/get.c:1486
    #14 0x7f74e1d41f18 in find_value ../src/mesa/main/get.c:1659
    #15 0x7f74e1d45166 in _mesa_GetIntegerv ../src/mesa/main/get.c:2027
    #16 0x557b58a7a31a in GL_Setup ../../../vid_shared.c:811
    #17 0x557b582c29b9 in VID_InitModeGL ../../../vid_sdl.c:1543
    #18 0x557b582c2cc6 in VID_InitMode ../../../vid_sdl.c:1593
    #19 0x557b58a7e8b9 in VID_Mode ../../../vid_shared.c:1373
    #20 0x557b58a7f34e in VID_Restart_f ../../../vid_shared.c:1475
    #21 0x557b58477fe5 in Cmd_ExecuteString ../../../cmd.c:1938
    #22 0x557b5847231a in Cbuf_Execute ../../../cmd.c:361
    #23 0x557b58472469 in Cbuf_Frame ../../../cmd.c:383
    #24 0x557b585dfc4e in Host_Main ../../../host.c:779
    #25 0x557b582b9331 in main ../../../sys_sdl.c:218
    #26 0x7f74df5e0ca7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
...
SUMMARY: AddressSanitizer: 19110630 byte(s) leaked in 109361 allocation(s).














# https://github.com/DarkPlacesEngine/DarkPlaces/commit/72d993ebe1069e0813747379d0878d5c335f6b08.patch

wget https://github.com/DarkPlacesEngine/DarkPlaces/commit/72d993ebe1069e0813747379d0878d5c335f6b08.patch -O debian/patches/upstream-72d993ebe1069e0813747379d0878d5c335f6b08.patch
echo upstream-72d993ebe1069e0813747379d0878d5c335f6b08.patch >> debian/patches/series
quilt push
export DEB_CFLAGS_APPEND=-fsanitize=address                       
export DEB_CPPFLAGS_APPEND=-fsanitize=address
export DEB_CXXFLAGS_APPEND=-fsanitize=address
export DEB_LDFLAGS_APPEND=-fsanitize=address
DEB_BUILD_OPTIONS="nostrip noopt" dpkg-buildpackage -b

/home/benutzer/asan_.darkplaces.30111

SUMMARY: AddressSanitizer: 9952184 byte(s) leaked in 3306 allocation(s).
















# Build without ASan again:

unset DEB_CFLAGS_APPEND
unset DEB_CPPFLAGS_APPEND
unset DEB_CXXFLAGS_APPEND
unset DEB_LDFLAGS_APPEND
DEB_BUILD_OPTIONS="nostrip noopt" dpkg-buildpackage -b


More information about the Pkg-games-devel mailing list