KallistiOS icon indicating copy to clipboard operation
KallistiOS copied to clipboard

ping example leaks memory on shutdown

Open QuzarDC opened this issue 8 months ago • 1 comments

I tried following the calls back into the networking code but could not see where this was happening. This doesn't appear in the 'basic' test so it's not just from enabling networking, it must be something happening behind the icmp. Unfortunately the newlib calls that cause it are merely to balloc inside of stdlib/mprec so it could still be any number of stdlib functions that are behind it.

I don't think this should be blocking to v2.1.0, but found it during testing and wanted to make sure it got documented.

Just as an FYI on all of these the 'in use bytes' at the end of the malloc stats will be inflated from the actual number due to the memory overhead of using KM_DBG to get which blocks were leaked.

  Fri Jun 14 06:46:10 AM EDT 2024
  quzar@Centurion-IV.:/home/quzar/dcdev/KallistiOS
  sh-elf-gcc (GCC) 15.0.0 20240522 (experimental)
thd: pre-emption enabled, HZ=100
maple: active drivers:
    Dreameye (Camera): Camera
    Sound Input Peripheral: Microphone
    PuruPuru (Vibration) Pack: JumpPack
    VMU Driver: Clock, LCD, MemoryCard
    Mouse Driver: Mouse
    Keyboard Driver: Keyboard
    Controller Driver: Controller
    Lightgun: LightGun
  DMA Buffer at ac0a2be0
vid_set_mode: 640x480 VGA with 1 framebuffers.
lan: no device detected
dc-load console support enabled
maple: attached devices:
  A0: Dreamcast Controller           (01000000: Controller)
  A1: Visual Memory                  (0e000000: Clock, LCD, MemoryCard)
  A2: Puru Puru Pack                 (00010000: JumpPack)
  B0: Dreamcast Camera Flash  Device (01000000: Controller)
  B1: Dreamcast Camera Flash LDevice (00080000: Camera)
  B2: Dreamcast Camera Flash LDevice (00080000: Camera)
  B3: Dreamcast Camera Flash LDevice (00080000: Camera)
  B4: Dreamcast Camera Flash LDevice (00080000: Camera)
  B5: Dreamcast Camera Flash LDevice (00080000: Camera)
bba: MAC Address is 00:d0:f1:02:a5:a6
bba: link lost
bba: link stable
net_dev_init: detected 1 usable network device(s)

72 bytes from 192.168.1.1: icmp_seq=0 ttl=64 time=5.150 ms
72 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=2.854 ms
72 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=3.143 ms
72 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=1.194 ms
72 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=3.382 ms
72 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=3.647 ms
72 bytes from 192.168.1.1: icmp_seq=6 ttl=64 time=3.314 ms
72 bytes from 192.168.1.1: icmp_seq=7 ttl=64 time=3.458 ms
72 bytes from 192.168.1.1: icmp_seq=8 ttl=64 time=3.524 ms
72 bytes from 192.168.1.1: icmp_seq=9 ttl=64 time=1.795 ms

arch: exit return code 0
arch: shutting down kernel
maple: final stats -- device count = 9, vbl_cntr = 656, dma_cntr = 647
vid_set_mode: 640x480 VGA with 1 framebuffers.
max system bytes =     360332
system bytes     =     360332
in use bytes     =       1788
KM_DBG: Still-allocated memory blocks:
  INUSE 8c0cecb8: size 24, thread 4, addr 8c03f522, type calloc
  INUSE 8c0ce1a0: size 28, thread 4, addr 8c03f522, type calloc
  INUSE 8c0cdef8: size 132, thread 4, addr 8c03f506, type calloc
quzar@Centurion-IV:~/dcdev/KallistiOS/examples/dreamcast/network/ping$ $KOS_ADDR2LINE -e ping.elf
8c03f522
/home/quzar/dcdev/KallistiOS/utils/dc-chain/build-newlib-sh-elf-4.4.0.20231231/sh-elf/newlib/../../../newlib-4.4.0.20231231/newlib/libc/stdlib/mprec.c:132
8c03f522
/home/quzar/dcdev/KallistiOS/utils/dc-chain/build-newlib-sh-elf-4.4.0.20231231/sh-elf/newlib/../../../newlib-4.4.0.20231231/newlib/libc/stdlib/mprec.c:132
8c03f506
/home/quzar/dcdev/KallistiOS/utils/dc-chain/build-newlib-sh-elf-4.4.0.20231231/sh-elf/newlib/../../../newlib-4.4.0.20231231/newlib/libc/stdlib/mprec.c:114

QuzarDC avatar Jun 14 '24 16:06 QuzarDC