Date: Thu, 31 Jul 2025 16:59:02 +0100
thiago I did give a good motovation for MAX_INVALID_ADDRES, it's your
*opinion* that it's not. either way I've said my piece and I have neither
the time nor the inclination to argue until the cows come home that I'm
right.
On Thu, 31 Jul 2025 at 16:41, Thiago Macieira <thiago_at_[hidden]> wrote:
> On Thursday, 31 July 2025 08:23:08 Pacific Daylight Time zxuiji wrote:
> > It's useful to know a standard range to apply. For example libraries like
> > boost could detect if pointers passed to them are in said range and catch
> > the problem before a segfault can happen. They can in turn exit the
> thread
> > but not the whole app/game/etc.
>
> I disagree on THAT motivation. An invalid pointer is an invalid pointer
> and
> passing it violates the generic preconditions of any function. Do it at
> your
> own peril, because the callee has no obligation to verify with the OS that
> it
> is valid. And since you mentioned threading, any answer of whether it is
> valid
> or not is also racy.
>
> What I can see a reason for is to use the pointer as a union for other
> content. We use it in QMutex, for example, to indicate an uncontended
> mutex.
> We are sure that any address ±alignof(max_align_t) of null is invalid, as
> are
> misaligned pointers for the object type in question.
>
> We *could* use more bits (10 instead of 3) for other uses, but quite
> frankly
> haven't needed.
>
> So as usual: start with a good motivation for this.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Principal Engineer - Intel Platform & System Engineering
>
>
>
>
*opinion* that it's not. either way I've said my piece and I have neither
the time nor the inclination to argue until the cows come home that I'm
right.
On Thu, 31 Jul 2025 at 16:41, Thiago Macieira <thiago_at_[hidden]> wrote:
> On Thursday, 31 July 2025 08:23:08 Pacific Daylight Time zxuiji wrote:
> > It's useful to know a standard range to apply. For example libraries like
> > boost could detect if pointers passed to them are in said range and catch
> > the problem before a segfault can happen. They can in turn exit the
> thread
> > but not the whole app/game/etc.
>
> I disagree on THAT motivation. An invalid pointer is an invalid pointer
> and
> passing it violates the generic preconditions of any function. Do it at
> your
> own peril, because the callee has no obligation to verify with the OS that
> it
> is valid. And since you mentioned threading, any answer of whether it is
> valid
> or not is also racy.
>
> What I can see a reason for is to use the pointer as a union for other
> content. We use it in QMutex, for example, to indicate an uncontended
> mutex.
> We are sure that any address ±alignof(max_align_t) of null is invalid, as
> are
> misaligned pointers for the object type in question.
>
> We *could* use more bits (10 instead of 3) for other uses, but quite
> frankly
> haven't needed.
>
> So as usual: start with a good motivation for this.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Principal Engineer - Intel Platform & System Engineering
>
>
>
>
Received on 2025-07-31 15:44:58