On Wed, Feb 28, 2024 at 9:29 AM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote: > > On Wed, 2024-02-28 at 10:29 -0600, David Vernet wrote: > [...] > > > Modulo the leak pointed out by Kui-Feng in another thread. It would be nice if > > we could just do this on the stack, but I guess there's no static max size for > > a tname. > > GCC documents [0] that it does not impose name length limits. > Skimming through libbpf's btf.c it looks like it does not impose limits either. > I can add a name buffer and a fallback to strdup logic if tname is too long, > but I don't think this code would ever be on the hot path. It would still be nice to avoid allocation even if for the sake of simplifying error handling. I think it's reasonable to have `char name[256]` on the stack and snprintf() into it. Let's keep it simple. > > [0] https://gcc.gnu.org/onlinedocs/gcc/Identifiers-implementation.html#Identifiers-implementation