🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3873

Re: Referencing pointers after delete

#3873
From: Martin D Kealey
Date: Sun, 31 Mar 1996 15:12
42 lines
2815 bytes
Tom Payne <thp@cs.ucr.edu> wrote:
> Steve Clamage (clamage@Eng.Sun.COM) wrote:
> : I don't see any advantage in trying to restrict the kind or form of checking
> : that systems are allowed to implement. I would applaud a hardware-based
> : mechanism, and I would resent a programming language standard that made
> : it non-conforming.
> The issue is not the form of the checking but the response to it.  The
> standard response to a hardware-detected fault is to invoke a signal
> handler, which is (or should be) completely conforming.

Consider this implementation with NO run-time pointer checking (as
is allowed) where every object contains not only a vtable pointer
but also an owner-task pointer as well, used for inter-process
memory management.

Now, if we run out of normal registers and it is necessary to
spill the "current task" register, its value can be reloaded
through any register pointing at an object (say because register-
indirect might be faster than absolute addressing). The compiler
writer knows this will only be done if a valid pointer value is
already in a register (and calling delete will invalidate the
register), since it would be more economical to obtain the value
some other way if a pointer to it isn't available).

However, using the value in an expression might cause a register
to get re-loaded with that value, so that reloading the task
pointer could go wrong; in a system with an unprotected memory
space, corrupting the task pointer could indeed be the equivalent
of "halt and catch fire".

Is there anything in such an implementation that is unconforming?
If not, then I submit that "undefined behaviour" IS the correct
term to apply to *any* use of an invalidated pointer value.

-Martin.


[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
Technical Details
Message-ID: <m0u3D8A-000GcEC@7.kurahaupo.gen.nz>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: martin@kcbbs.gen.nz (Martin D Kealey)
Newsgroups: comp.std.c++
Subject: Re: Referencing pointers after delete
Date: 31 Mar 1996 15:12:42 GMT
Organization: ?
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <m0u3D8A-000GcEC@7.kurahaupo.gen.nz>
NNTP-Posting-Host: taumet.eng.sun.com
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Cc: std-c++@ncar.ucar.edu
In-Reply-To: <4j6k0r$hev@galaxy.ucr.edu> from "Tom Payne" at Mar 25, 96 05:27:32 pm
X-Mailer: ELM [version 2.4 PL24]
Content-Length: 1734
Originator: clamage@taumet