On Sun, Aug 31, 2025 at 08:14:21AM +1000, Richard Henderson wrote:
> On 8/30/25 04:03, Daniel P. Berrangé wrote:
> > +#ifndef PTHREAD_MAX_NAMELEN_NP
> > +#define PTHREAD_MAX_NAMELEN_NP 16
> > +#endif
> > +
> > +static __thread char namebuf[PTHREAD_MAX_NAMELEN_NP];
>
> If you're going to have this...
>
> > +static __thread char namebuf[64];
>
> ... or this, why not just remember the name from when we set it?
>
> You could even store a pointer instead of a larger number of characters.
> I'll note that all of the names we actually pass to qemu_thread_create are
> string literals, and that we don't actually need to do any memory allocation
> at all with them.
I was thinking about the possibility there will be threads running that
were not created using qemu_thread_start, given that libraries use threads
behind the scenes and I can't rule out possibility that such threads call
back into QEMU code.
>
>
> > + name = g_utf16_to_utf8(namew, -1, NULL, NULL, NULL);
> > + LocalFree(namew);
> > + if (!name) {
> > + goto error;
> > + }
>
> That would certainly avoid this kind of hassle.
>
>
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|