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

Keith Packard <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
Ola Olsson <[email protected]> writes:

> 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.

Yeah, picolibc has only been around for a couple of years...

> 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.

The nano malloc in newlib doesn't handle the memalign call correctly,
which I suspect you aren't using. It's also has more overhead than the
picolibc version as it adds variable padding between the header and the
allocation.

> 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?

The generated code is smaller, the allocation overhead is lower and the
API is more robust against invalid API usage.

> 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.

If someone wants to work on your patches in newlib, that's fine; they're
definitely an improvement over the current code. My work is focused on
picolibc, and when I have some time, I try to get fixes merged into
newlib.

-- 
-keith
signature.asc (application/pgp-signature, 832 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEw4O3eCVWE9/bQJ2R2yIaaQAAABEFAmCJz78ACgkQ2yIaaQAA
ABHJsxAArTdpdnnlKLro2VtQneSeItvxsryfjIG+iVZBfG/r8YhEPNIjQY382e0E
/nmZXhllZNyiui1xButQNfZQFBeewuB1FbeaExNIHn3GsaOqkdK0VOn2Fi/6T9Wl
QGUW7xE9bNG2wyGcMG8ZFqnpbv3KvQEO/obtGHJ2aE2cbe2tRclGyivRADMns/Rv
eqBbt+4LArzYM/FupX0DorulE1qEYyeZBR23AvPQ7uQ5XQEJqDeObVVMpA6fijHU
wiRr4YqVMcQhscQpnp5EfKKZBum2b/XnjMN9zIAM7mMaNZ630RrVeMjc/kfPKTjl
wM77/fon+7Z53U//QfhIDVv7QcLKRY7LmlJRIyGDIwhZ+eJKws240cXy+LOfbLqM
eOMCpxs0wrhBEUiVnozzWR78j6Qzjr2iaUgFjJvLQxBhBIZmSahRn34241WzzJu+
MP8PwVvjyYEL2ia4THg6GcaiUnqe/AgMpgJMw3IKmN6+RhEWAwEwLNVl2tYJ28XE
97aUo/d0PKRI/zoQwSYi30uWbs+x4gK3jzQc4oFF+L9CBQZrEh+dBKBpBlrGZ/eE
VxOVWLsFunpOOGx3z2N9B+eeIPnmSMIuYk1njLxE7LKOfVjl8SKY5dtKgVGE4LST
qNbM0Jo91HcJZcxvFrJaGGvTb4Hr3MePHYw0XJN8MT9Kw0Lkhkc=
=zWQ0
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.