Are there tools to help find memory leaks, buffer overruns, etc?
Yes! You’ll need to have built your own KOS to use it though. You have two options: turning on debugging in the standard malloc, and replacing malloc with a debug version. The former is definitely the recommended choice for most usage, and it’s not a bad idea to leave it on while developing. Edit kernel/libc/koslib/malloc.c, and look at the #define’s at the top. ‘DEBUG’ turns on internal checks in the malloc functions (mostly assert statements). These are basic and not too helpful unless you have a catastrophic failure. KM_DBG enables KOS memory debugging. This turns on “canary” zones before and after each block and tracks all allocated blocks in a linked list to find leaks. Combined with the INIT_MALLOCSTATS flag, you can see exactly where a piece of memory was allocated, which thread allocated it, the size, and so on. Using the sh-elf-addr2line util mentioned above, it’s easy to hunt down where the leak happened. KM_DBG_VERBOSE is like a sledge hammer to KM_DBG’s claw hammer. You hav