Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CACC_My-UEnebn0wqCKSNVkBCXgAZNaQPY7+7X8X+yB8vo3LuCA@mail.gmail.com>
Date: Wed, 14 Oct 2026 21:14:05 +0200
From: Lukas Tribus <lukas@...i.eu>
To: Rich Felker <dalias@...c.org>
Cc: musl@...ts.openwall.com, rafamiga <rafamiga@...il.com>
Subject: Re: Type confusion in include/sched.h (was: Discrepancy in include/sched.h – breaks haproxy's CPU topology discovery)

Hello,

On Tue, 8 Sept 2026 at 01:52, Rich Felker <dalias@...c.org> wrote:
>
> On Sun, Mar 22, 2026 at 04:41:41PM +0100, Lukas Tribus wrote:
> > Dear list,
> >
> >
> > On Fri, 5 Sept 2025 at 21:23, rafamiga <rafamiga@...il.com> wrote:
> > >
> > > While working on a fix for haproxy load balancer running in a container built with musl a discrepancy was found in include/sched.h. Long story short, on a 48 CPU system haproxy was reporting just 32 CPUs. I'm forwarding findings to this list to let you know that a change might be considered.
> > >
> > > Original bug report: https://github.com/haproxy/haproxy/issues/3103
> > >
> > > Citing the author (wtarreau):
> > >
> > > Oh I think I found it! The issue is here in sched.h:
> > >
> > > #define __CPU_op_S(i, size, set, op) ( (i)/8U >= (size) ? 0 : \
> > > (((unsigned long *)(set))[(i)/8/sizeof(long)] op (1UL<<((i)%(8*sizeof(long))))) )
> > >
> > > but CPU_ISSET() is defined as:
> > >
> > > #define CPU_ISSET(i, set) CPU_ISSET_S(i,sizeof(cpu_set_t),set)
> > >
> > > See ? It returns an unsigned long which is returned as-is by the macro. However the man says that CPU_ISSET() must return an int. So in our case it's returned as-is and truncated to the lowest 32 bits.
> > >
> > > The fix for the lib would be simple:
> > >
> > > -#define CPU_ISSET(i, set) CPU_ISSET_S(i,sizeof(cpu_set_t),set)
> > > +#define CPU_ISSET(i, set) (CPU_ISSET_S(i,sizeof(cpu_set_t),set) != 0)
> > >
> > > It should be reported to the project.
> >
> >
> > Any feedback on the above report regarding a unsigned long vs int type
> > mismatch and the change suggested by Willy Tarreau?
>
> Sorry this got overlooked. I'm fixing it now.

Thank you!


Lukas

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.