FAQ
Nick Ing-Simmons wrote
Mike Guy <mjtg@cam.ac.uk> writes:
Repeat until there are no more such objects (since DESTROY could
create new ones).
This step may never complete if DESTROY always creates a new one...
Yes; that's entirely deliberate. If you're allowing arbitrary user
code, as in a DESTROY routine, you can't avoid the possibility of
loops. The user could have written the body of the DESTROY as

0 while 1;

I see no point in messing up the semantics to deal with only one
special case.

After this point, no more user code should be obeyed.
What about XS code?
I was trying to say that it shouldn't be possible to run user code
after this, whether pure Perl or XS, because all hooks have been removed.

There are a couple of user-visible ways in which this differs from the
current code. END {} blocks are currently called *after* sv_clean_objs().
I don't think so. I have END blocks that get called while objects
still exist.
Yes, you're quite right. That was a brain fart. I'd somehow got it
into my head that the PL_exitlist stuff was something to do with END {}
blocks, which of course it isn't. All mention of END {} blocks in the
proposal is nonsense and should be deleted. They have (I presume)
been dealt with much earlier. (I did say the proposal was half-baked.)

But that does raise the question of the Perl_call_atexit() stuff and
where it fits in the scheme of things. I presume it's for the benefit
of extensions, but I can find no mention in the documentation.

Is it intended to be used only by modules bundled with the core,
or is it intended to be public?

We need to lay down rules for what such routines are allowed to do.
A simple rule would seem to be "Don't create any new blessed objects".
I note that the routine in Dynaloader/dlutils.c calls a subroutine
DynaLoader::dl_unload_file which the user could have interfered with ...


Here's take 2:

a) Scan all SVs, looking for blessed objects whose DESTROY routines
haven't been called. Set a (new) flag in the SV saying DESTROY
has been called, and call it.

Repeat until there are no more such objects (since DESTROY could
create new ones).

b) Delete all %SIG entries, in particular $SIG{__DIE__} and
$SIG{__WARN__} .

After this point, it should not be possible for user code to be obeyed,
since we've (hopefully) removed all the hooks. As belt and braces,
this could be enforced, e.g. by plugging the OP dispatch loop.

c) Call all PL_exitlist functions.
Do we need to do (a) again "just in case"?

d) Delete all "special" variables.

e) Scan all SVs looking for pointers to other SVs, e.g. references
or fields in GVs. Nullify the pointer and SvREFCNT_dec the
referent.

After this nothing should be pointing at any SV, so there is no danger
of dangling references.

f) Scan all SVs freeing them.


Mike Guy

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
categoriesperl
postedAug 31, '00 at 4:14p
activeAug 31, '00 at 4:14p
posts1
users1
websiteperl.org

1 user in discussion

Mike Guy: 1 post

People

Translate

site design / logo © 2022 Grokbase