Re: mallinfo arena and uordblks unintialized?

Grant Edwards <[email protected]> Tue, 17 Feb 2026 04:49:10 -0000 (UTC)
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On 2026-02-17, Grant Edwards <[email protected]> wrote:

> I've implmented _sbrk_r() and have been testing malloc().  It's
> calling _sbrk_r() as expected. I can see that _sbrk_r() runs out of
> memory and malloc() fails after I've allocated the "expected" max
> amount of memory.
>
> What's odd are the values returned by mallinfo().
>
> The initial values of arena and uordblks are a  large, apparently
> random number.  For example, before the first malloc() call:
>
>     arena=4695456 ordblks=0, uordblks=4695456, fordblks=0

I finally noticed that the initial value for arena/uordblks isn't
random. It's the final value they were at before the program image was
reloaded into RAM and restarted.

Whats odd is that all other initialized static variables are starting
with their expected values, and uninititialized static variables are
getting set to zero as expected. AFAICT .bss and .data sections are
getting correctly initialized by startup code. Where is the mallinfo
data stored?

--
Grant