summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2010-11-22 19:18:49 +0000
committerDavid Mitchell <davem@iabyn.com>2010-11-26 16:01:34 +0000
commitabf9167d3fff002ddaed53abb44d638387bca978 (patch)
treef81a5b1c720adff647b3866f0a7b7890b444534b /toke.c
parentcc6623a84b782d30463b9046c2916f35064a7e3f (diff)
downloadperl-abf9167d3fff002ddaed53abb44d638387bca978.tar.gz
Make PerlIO marginally reentrant
Currently if an operation on a file handle is interrupted, and if the signal handler accesses that same file handle (e.g. closes it), then perl will crash. See [perl #75556]. This commit provides some basic infrastructure to avoid segfaults. Basically it adds a lock count field to each handle (by re-purposing the unused flags field in the PL_perlio array), then each time a signal handler is called, the count is incremented. Then various parts of PerlIO use a positive count to change behaviour. Most importantly, when layers are popped, the PerlIOl structure is cleared, but not freed, and is left in the chain of layers. This means that callers still holding pointers to the various layers won't access freed structures. It does however mean that PerlIOl structs may be leaked, and possibly slots in PL_perlio. But this is better than crashing. Not much has been done to give sensible behaviour on re-entrancy; for example, a buffer that has already been written once might get written again. Fixing this sort of thing would require a large-scale audit of perlio.c.
Diffstat (limited to 'toke.c')
0 files changed, 0 insertions, 0 deletions