C++ Logo

sg14

Advanced search

Re: [SG14] [isocpp-parallel] (SC22WG14.16350) Rough notes from SC22 WG21 SG14 meeting on pointer lifetime-end zap

From: Niall Douglas <s_sourceforge_at_[hidden]>
Date: Thu, 2 May 2019 11:24:08 +0100
>> The utility of this is that pointers could retain a version counter,
>> such that we can detect, at runtime, whether dereferencing a pointer to
>> a dead object is occurring. I think this would be extremely valuable in
>> a future C or C++ implementation, if CPU hardware adds some acceleration
>> for this kind of invalid pointer dereference checking.
>
> Ah, ok. I see the motivation, though I wonder about its effect on
> uses of compare-and-swap on such pointers - Paul/Hans?

The issue, specifically, would arise when people cast pointers to
uintptr_t, and do a CAS on those.

(For CAS on known pointers, the implementation can mask off the version
counter bits before use in CAS. One could mask off the version counter
bits when casting a pointer to uintptr_t, but then one cannot restore an
exact pointer value from a pointer to integer back to pointer cast. One
effectively would "lose" the version counter. This may not break
anything, except the usefulness of the runtime checker, and this may be
an acceptable tradeoff)

Niall

Received on 2019-05-02 05:25:59