<s>
Tombstones	B-Language
are	O
a	O
mechanism	O
to	O
detect	O
dangling	B-Error_Name
pointers	I-Error_Name
and	O
mitigate	O
the	O
problems	O
they	O
can	O
cause	O
in	O
computer	O
programs	O
.	O
</s>
<s>
Dangling	B-Error_Name
pointers	I-Error_Name
can	O
appear	O
in	O
certain	O
computer	O
programming	O
languages	O
,	O
e.g.	O
</s>
<s>
C	B-Language
,	O
C++	B-Language
and	O
assembly	B-Language
languages	I-Language
.	O
</s>
<s>
A	O
tombstone	B-Language
is	O
a	O
structure	O
that	O
acts	O
as	O
an	O
intermediary	O
between	O
a	O
pointer	O
and	O
its	O
target	O
,	O
often	O
heap-dynamic	B-General_Concept
data	O
in	O
memory	B-Architecture
.	O
</s>
<s>
The	O
pointer	O
–	O
sometimes	O
called	O
the	O
handle	O
–	O
points	O
only	O
at	O
tombstones	B-Language
and	O
never	O
to	O
its	O
actual	O
target	O
.	O
</s>
<s>
When	O
the	O
data	O
is	O
deallocated	O
,	O
the	O
tombstone	B-Language
is	O
set	O
to	O
a	O
null	O
(	O
or	O
,	O
more	O
generally	O
,	O
to	O
a	O
value	O
that	O
is	O
illegal	O
for	O
a	O
pointer	O
in	O
the	O
given	O
runtime	O
environment	O
)	O
,	O
indicating	O
that	O
the	O
variable	O
no	O
longer	O
exists	O
.	O
</s>
<s>
This	O
mechanism	O
prevents	O
the	O
use	O
of	O
invalid	O
pointers	O
,	O
which	O
would	O
otherwise	O
access	O
the	O
memory	B-Architecture
area	O
that	O
once	O
belonged	O
to	O
the	O
now	O
deallocated	O
variable	O
,	O
although	O
it	O
may	O
already	O
contain	O
other	O
data	O
,	O
in	O
turn	O
leading	O
to	O
corruption	O
of	O
in-memory	O
data	O
.	O
</s>
<s>
Depending	O
on	O
the	O
operating	B-General_Concept
system	I-General_Concept
,	O
the	O
CPU	B-General_Concept
can	O
automatically	O
detect	O
such	O
an	O
invalid	O
access	O
(	O
e.g.	O
</s>
<s>
In	O
more	O
generalized	O
terms	O
,	O
a	O
tombstone	B-Language
can	O
be	O
understood	O
as	O
a	O
marker	O
for	O
"	O
this	O
data	O
is	O
no	O
longer	O
here	O
"	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
filesystems	B-Application
it	O
may	O
be	O
efficient	O
when	O
deleting	O
files	O
to	O
mark	O
them	O
as	O
"	O
dead	O
"	O
instead	O
of	O
immediately	O
reclaiming	O
all	O
their	O
data	O
blocks	O
.	O
</s>
<s>
The	O
downsides	O
of	O
using	O
tombstones	B-Language
include	O
a	O
computational	O
overhead	O
and	O
additional	O
memory	B-Architecture
consumption	O
:	O
extra	O
processing	O
is	O
necessary	O
to	O
follow	O
the	O
path	O
from	O
the	O
pointer	O
to	O
data	O
through	O
the	O
tombstone	B-Language
,	O
and	O
extra	O
memory	B-Architecture
is	O
necessary	O
to	O
retain	O
tombstones	B-Language
for	O
every	O
pointer	O
throughout	O
the	O
program	O
.	O
</s>
<s>
One	O
other	O
problem	O
is	O
that	O
all	O
the	O
code	O
that	O
needs	O
to	O
work	O
with	O
the	O
pointers	O
in	O
question	O
needs	O
to	O
be	O
implemented	O
to	O
use	O
the	O
tombstone	B-Language
mechanism	O
.	O
</s>
<s>
Among	O
popular	O
programming	O
languages	O
,	O
C++	B-Language
implements	O
the	O
tombstone	B-Language
pattern	O
in	O
its	O
standard	O
library	O
as	O
a	O
weak	O
pointer	O
using	O
std::weak_ptr	O
.	O
</s>
