MPD crash on openwrt

Hi guys

First, congratulations for the new openwrt.org website.

I'm using omega2 and hilink boards around my house to play audio using mpd. Last openwrt version I was using was very old (~ v14), and recently I've started to use 21.02.2.

Using 21.02 (just the current stable version at openwrt website) I've detected an issue related to dynamic memory allocation, that is not related to mpd it self, because testing same mpd version in my desktop pc works without problem, even I can seen the memory never reaches more thatn 8MB.

Basically, when I reproduce a file from my local server http://192.168.33.217:8090/music.mp3 it throws an OUT OF MEMORY error. When I reproduce same file locally it plays well. The odd thing is that music.mp3 file size is 200MB.
Related info:

C[  397.700126] oom_reaper: reaped process 3375 (top), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
[  397.791454] hostapd invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=0
[  397.810435] CPU: 0 PID: 1406 Comm: hostapd Not tainted 5.4.179 #0
[  397.822514] Stack : 00000240 8005aeec 805d0000 805679e8 00000000 00000000 00000000 00000000
[  397.839081]         00000000 00000000 00000000 00000000 00000000 00000001 875d9bb0 22f29858
[  397.855644]         875d9c48 00000000 00000000 00000000 00000038 804f2ec4 2e352064 37312e34
[  397.872208]         00000000 00000013 00000000 000c5dc3 80000000 875d9b90 87d6ba80 00000000
[  397.888774]         00000000 805cde14 00000000 00100cca 00000000 802b9f0c 00000000 80700000
[  397.905340]         ...
[  397.910188] Call Trace:
[  397.910199] [<8005aeec>] 0x8005aeec
[  397.921955] [<805d0000>] 0x805d0000
[  397.928906] [<804f2ec4>] 0x804f2ec4
[  397.935835] [<802b9f0c>] 0x802b9f0c
[  397.942762] [<80009790>] 0x80009790
[  397.949679] [<80009798>] 0x80009798
[  397.956604] [<800cf888>] 0x800cf888
[  397.963554] [<800d0320>] 0x800d0320
[  397.970482] [<800d0ae8>] 0x800d0ae8
[  397.977399] [<80110bcc>] 0x80110bcc
[  397.984339] [<800cbbbc>] 0x800cbbbc
[  397.991252] [<80069758>] 0x80069758
[  397.998211] [<800cc380>] 0x800cc380
[  398.005126] [<804f7b5c>] 0x804f7b5c
[  398.012049] [<804efda0>] 0x804efda0
[  398.018965] [<800c8ffc>] 0x800c8ffc
[  398.025904] [<800f6cfc>] 0x800f6cfc
[  398.032828] [<800fbce8>] 0x800fbce8
[  398.039749] [<80186a9c>] 0x80186a9c
[  398.046701] [<800101d4>] 0x800101d4
[  398.053626] [<80015cec>] 0x80015cec
[  398.060552]
[  398.063507] Mem-Info:
[  398.068039] active_anon:23298 inactive_anon:7 isolated_anon:0
[  398.068039]  active_file:28 inactive_file:106 isolated_file:0
[  398.068039]  unevictable:0 dirty:0 writeback:0 unstable:0
[  398.068039]  slab_reclaimable:238 slab_unreclaimable:1254
[  398.068039]  mapped:2 shmem:250 pagetables:105 bounce:0
[  398.068039]  free:4079 free_pcp:15 free_cma:0
[  398.131052] Node 0 active_anon:93192kB inactive_anon:28kB active_file:112kB inactive_file:424kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:8kB dirty:0kB writeback:0kB shmem:1000kB writeback_tmp:0kB unstable:0kB all_unreclaimable? yes
[  398.175153] Normal free:16316kB min:16384kB low:20480kB high:24576kB active_anon:93192kB inactive_anon:28kB active_file:112kB inactive_file:424kB unevictable:0kB writepending:0kB present:131072kB managed:123580kB mlocked:0kB kernel_stack:400kB pagetables:420kB bounce:0kB free_pcp:60kB local_pcp:60kB free_cma:0kB
[  398.229887] lowmem_reserve[]: 0 0
[  398.236461] Normal: 119*4kB (UE) 58*8kB (UME) 37*16kB (UME) 14*32kB (ME) 4*64kB (UME) 2*128kB (UM) 0*256kB 1*512kB (U) 1*1024kB (U) 2*2048kB (UE) 2*4096kB (M) = 16316kB
[  398.266320] 384 total pagecache pages
[  398.273579] 0 pages in swap cache
[  398.280151] Swap cache stats: add 0, delete 0, find 0/0
[  398.290517] Free swap  = 0kB
[  398.296228] Total swap = 0kB
[  398.301936] 32768 pages RAM
[  398.307473] 0 pages HighMem/MovableOnly
[  398.315072] 1873 pages reserved
[  398.321297] Tasks state (memory values in pages):
[  398.330620] [  pid  ]   uid  tgid total_vm      rss pgtables_bytes swapents oom_score_adj name
[  398.347702] [    511]    81   511      315       20    20480        0             0 ubusd
[  398.363911] [    512]     0   512      315       11    16384        0             0 ash
[  398.379779] [    546]     0   546      261       12    12288        0             0 urngd
[  398.395992] [    806]     0   806     1006       37    24576        0             0 uhttpd
[  398.412375] [   1051]   514  1051      316       23    20480        0             0 logd
[  398.428416] [   1103]     0  1103      521       42    20480        0             0 rpcd
[  398.444455] [   1308]     0  1308      287       11    16384        0             0 dropbear
[  398.461183] [   1406]     0  1406     1070       27    24576        0             0 hostapd
[  398.477739] [   1407]     0  1407     1070       27    24576        0             0 wpa_supplicant
[  398.495499] [   1469]     0  1469      449       38    16384        0             0 netifd
[  398.511882] [   1525]     0  1525      370       27    20480        0             0 odhcpd
[  398.528266] [   1983]     0  1983      313       10    16384        0             0 udhcpc
[  398.544648] [   1985]     0  1985      267       13    16384        0             0 odhcp6c
[  398.561203] [   2170]   453  2170      348       22    12288        0             0 dnsmasq
[  398.577759] [   2414]     0  2414      314       11    12288        0             0 ntpd
[  398.593796] [   3354]     0  3354    32608    22706   122880        0             0 mpd
[  398.609664] [   3375]     0  3375      313        0    12288        0             0 top
[  398.625525] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),global_oom,task_memcg=/,task=mpd,pid=3354,uid=0
[  398.645590] Out of memory: Killed process 3354 (mpd) total-vm:130432kB, anon-rss:90820kB, file-rss:4kB, shmem-rss:0kB, UID:0 pgtables:120kB oom_score_adj:0
[  400.730452] oom_reaper: reaped process 3354 (mpd), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB

[1]+  Killed                     mpd mpd.conf

top output

Mem: 102036K used, 21544K free, 1000K shrd, 2672K buff, 7320K cached
CPU:  37% usr  26% sys   0% nic   0% idle   0% io   0% irq  35% sirq
Load average: 0.50 0.61 0.34 3/50 3375
  PID  PPID USER     STAT   VSZ %VSZ %CPU COMMAND
 3354   512 root     S     127m 105%  94% mpd mpd.conf

Well if the OOM killer kicks in, that means you are running out of memory at that point either way. Why is the size odd? Is your RAM bigger than the file? Looks like you might have 128 MB RAM. And 100 MB of that used already?

@Borromini I was referring that file size is very big (about 100MB). openwrt box has 128MB of RAM.
100MB are used at the moment I order mpd lo load file from http://192.168.33.217:8090/music.mp3. Same testing in a PC only takes 8MB. Same testing playing from SD or USB (using openwrt box) only takes 8MB.

In conclusion when reproducing from url (streaming), mpd tries to allocate same memory as the size of the file you try to play, and only occurs with openwrt

The error seems related to MUSL. If I choose glibc instead musl mpd works well

Any advice how to debug further such issue?

if mpd = https://musicpd.org/ , then try the memory settings..

Yes Music Player Daemon
What do you mean with memory parameters? Parameters in mpd.conf? Compilation flags?

As far as I know nothing relevant can help

conf file parameters, according to the official home page.

https://linux.die.net/man/5/mpd.conf is hardly the official conf reference page.