[PATCH] Nano-malloc: Fix for unwanted external heap fragmentation

Ola Olsson ola1olsson@gmail.com
Wed Apr 28 20:02:06 GMT 2021


Okay, now I follow. Thanks for the explanation. I have only heard about
newlib and newlib nano since these are the options I get through most
UI/SDK from MCU manufacturers.

> I'd encourage you to take a look at the picolibc changes and see if
> those look useful. I'm hoping to have some time to work on pushing them
> back to newlib as they'd be useful there as well.

It's quite a big diff between the current newlib nano-malloc code and the
nano-malloc in picolibc even though the strategy is the same. The code
definitely looks okay from my point of view but it feels overkill for me to
bring in an overwrite merge (or a bigger patch) right now when the only
thing I need is the small patch I provided. At least since I haven't seen
any more issues with the newlib nano version of malloc.
My experience with the newlib nano-malloc is limited though, maybe you are
aware of more bugs, or maybe the picolibc version is easier to maintain? Or
what is the rational of bringing in the picolibc version of nano-malloc?

I am of course fine with you bringing in the nano-malloc of picolibc but
I'd suggest to merge my patch in the meantime. The first reason is that I
am afraid that it will take time to get the fixes backported from picolibc.
The other reason is that I want to have a commit that I can use as
reference for bug checking if I find something fishy in the picolibc
version of nano-malloc.

/Ola

On Wed, Apr 28, 2021 at 8:19 PM Keith Packard <keithp@keithp.com> wrote:

> Ola Olsson <ola1olsson@gmail.com> writes:
>
> > Hi again,
> >
> > I am sorry but I have no idea what picolibc is and I haven't seen any
> > errata/todo or anything in newlib indicating that this issue will be
> fixed.
> > I am just a simple programmer; I pulled latest and greatest of newlib,
> used
> > "git log" and inspected the last 7 commits of nano-mallocr.c and then I
> was
> > back in year 2017...Hence, I pretty much came to the conclusion that this
> > issue won't be fixed unless I fix it myself.
>
> Oh, sorry, picolibc is a newlib fork designed for embedded systems
>
>         https://github.com/picolibc/picolibc
>
> Picolibc release 1.5.1 has the updated nano-malloc code in place. This
> is packaged in Debian unstable if you're using that. It also builds on
> Windows platforms.
>
> > Please tell me if there is anything I can do or if something is expected
> > from me regarding the patch before it's getting merged.
>
> I'd encourage you to take a look at the picolibc changes and see if
> those look useful. I'm hoping to have some time to work on pushing them
> back to newlib as they'd be useful there as well.
>
> > Btw, there are some cleanup I would like to do in this file as well,
> mostly
> > regarding comments and tabs->spaces but I guess it's okay to send a new
> > patch for that.
>
> I've been avoiding whitespace-only changes; I know the formatting is
> terrible, but fixing it means back-porting changes becomes very difficult.
>
> --
> -keith
>


More information about the Newlib mailing list