Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5235

Troubleshooting • Re: Malloc_Consolidate:() Invalid Chunk Size Error

$
0
0
malloc() and free() are not operating system calls, they are functions in the standard C library (usually). libc obtains memory from the OS by using the system call brk() to set the upper address limit of the heap.

Because only the top of heap can be adjusted, it is usually not possible (or desirable) for free() to return memory to the OS. Instead, memory that a program has freed remains with it, but is available for future mallocs.

Chunks of memory cannot be moved while they are in use, so the heap may become fragmented, but adjacent freed chunks can be consolidated into larger chunks.

The message "malloc_consolidate(): invalid chunk size" says that while libc was doing such internal housekeeping, it found a chunk with invalid size, which is an unrecoverable situation.

This corruption of the heap could be caused by a hardware problem, overclocking, etc. More likely there is a bug in the program such as writing beyond the bounds of an allocation, or continuing to use memory after freeing it, which eventually trashes some of libc's metadata.

If the crashing program is Python, then the bug may be in a Python module that is written in C. It should not really be possible to trash memory using pure Python code.

Statistics: Posted by jojopi — Tue Mar 26, 2024 12:47 am



Viewing all articles
Browse latest Browse all 5235

Trending Articles