develooper Front page | perl.perl5.porters | Postings from April 2006

thread non-safety in sv_setsv

Thread Next
Nicholas Clark
April 1, 2006 03:55
thread non-safety in sv_setsv
Message ID:
I've realised that there's the potential for some nasty thread unsafe code
in sv_setsv_flags, which seems to (mostly) sink any simple (read fast)
copy-on-write scheme.

The problem is that currently it's possible to quite legitimate pointer to
a (read only) SV in a parent thread, which you then pass to sv_setsv_flags to
copy *from*. sv_setsv_flags currently assumes that source and destination
are in the current interpreter, and is already doing copy-on-write of
shared hash key scalars:


So currently, if you happen to pass in a pointer to a shared hash key scalar
that lives in another thread, then manipulations will be made on data
structures that belong to *that* thread without any mutex protection, rather
than a clean copy made. I think that this only gets worse with any full
copy-on-write scheme, and also means that even the current code (in blead
only) isn't thread safe.

I'm not sure if there is a solution to this.

Nicholas Clark

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About