Dan Sugalski: # It's impossible to have clone in a threaded environment guarantee that it # won't deadlock.
If I recall correctly, all shared variables are owned by a single shared interpreter. What if, the first time the traversal encounters a shared PMC, it gets a lock on the shared interpreter? If a second traversal in another thread encountered another shared PMC, it would block until the first traversal was finished. (And if there isn't a shared interpreter, a global mutex would probably work just as well.) Pseudocode: bool seen_shared=false; ... if(PMC_is_shared(pmc)) { if(! seen_shared) { Interp_lock(shared_interpreter); seen_shared=true; } PMC_lock(pmc); } ... if(seen_shared) { Interp_unlock(shared_interpreter); } --Brent Dax <[EMAIL PROTECTED]> Perl and Parrot hacker "Yeah, and my underwear is flame-retardant--that doesn't mean I'm gonna set myself on fire to prove it."