On Fri, Aug 26, 2016 at 9:54 AM, Tobias Hunger <[email protected]> wrote:
> On Fri, Aug 26, 2016 at 5:08 PM, Christian Kandeler > <[email protected]> wrote: > > On 08/26/2016 04:49 PM, charleyb123 . wrote: > >> An aside: We are currently steeped in the tradition that "zero" is not > >> a legal address, but that is (quickly) becoming not-true for > >> process-containers, system-emulators and VMs, and new hardware > >> (including new CPUs). > > > > That has nothing to do with the null pointer in C(++). It never refers > > to a valid address, that's how the language is defined. > > 0 is a valid address. The OS usually makes sure the first page is not > mapped, thus triggering a segfault if you try to dereference 0 (or in > fact the first 4k or so, depending on page size). > > Linux had a security issue once where an attacker could map code into > the 0-page, triggering that code by accessing a > null-(function-)pointer. > > > If zero is a > > valid address in some environment, then it's the compiler's job to > > ensure that the null pointer maps to something else at runtime. > > I highly doubt that: 0 is a valid address, so the compiler can not > just go ahead and map it elsewhere as it pleases. Good points by Tobias, but I want to also elaborate to my original thought: On these new architectures, all bit-patterns for the native "address-type" are *user-process-addressable* as valid addresses (although an operating system may reserve some ranges, or impose OS-specific address partitioning restrictions, as Tobias explains). I know at present we can "cheat" with stuff like 64-bit pointers that merely rely upon 48-bit addressing for today's architectures, but that's an anachronism. --charley
_______________________________________________ Qt-creator mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/qt-creator
