Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 10 Feb 2023 09:35:02 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: musl@...ts.openwall.com
Cc: Rich Felker <dalias@...c.org>, Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH] search: provide twalk_r()

On Fri, Feb 10, 2023 at 3:18 AM Khem Raj <raj.khem@...il.com> wrote:
>
> On Thu, Feb 9, 2023 at 1:26 PM Bartosz Golaszewski <brgl@...ev.pl> wrote:
> >
> > On Thu, Feb 9, 2023 at 10:16 PM Rich Felker <dalias@...c.org> wrote:
> > >
> > > On Thu, Feb 09, 2023 at 09:43:42PM +0100, Bartosz Golaszewski wrote:
> > > > From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> > > >
> > > > Provide a variant of twalk() that allows callers to pass custom user
> > > > data to it without resorting to global variables.
> > > >
> > > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> > >
> > > Is there any precedent for this other than glibc, with matching
> > > signature and behavior? Without that, it looks like it's subject to
> > > the potential for conflicting definitions.
> > >
> >
> > Not sure what you mean. GLibc IS the precedent. This function has only
> > been around since glibc 2.30 (well, it's been 3 years) and requires
> > _GNU_SOURCE. It's a relatively new function but without it, twalk() is
> > quite useless.
>
> musl uses posix as its guiding light and sparingly implement other functions
>

I understand the musl philosophy but it already provides tdestroy()
which also happens to be a GNU extension.

These extensions exist for a reason - they are simply useful and
programs do use them out in the wild. twalk() on its own is brain-dead
and only useful to small programs that can afford to have global
variables. If you have a variable that tries to hold no global
context, then the possibility to pass data to the walk callback is
absolutely required. This is a general problem with those hash-map,
binary tree etc. APIs in POSIX - they don't seem to be designed very
well. GNU extensions try to address some of those issues.

> >
> > The background for this patch is: I have a low-level C library that I
> > maintain for which I try to limit external dependencies and I used
> > twalk_r() in the new version only to find out it doesn't build with
> > musl.
>
> maybe you should carry it as a fallback in your library and use it when building
> on libraries which do not provide it as a fall back.
>

That was my first thought but unfortunately struct node is not part of
the ABI and so user programs must not use it. In fact: it's not even
in the public header - callers only see a void pointer.

For me this means, that it's either limiting the availability of
libgpiosim to glibc, implementing my own binary search tree (that
would take up 300+ LOC for no reason and just end up copying existing
code anyway) or pulling in some library that provides it in C (which
would have to be something well maintained like GLib - which is huge)
just to get that single functionality which I'd really like to avoid.
In this context making musl provide twalk_r() upstream sounds like the
best solution and I'm sure my library is not the only user.

Please reconsider providing twalk_r() in musl.

Thanks
Bart

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.