Object lifetime in multi-threading applications
salva opened this issue · 1 comments
Currently, Net::SSH2
lacks support for being used in multi-threaded applications.
The most prominent issue being that the handling of Net::SSH2
objects lifetime doesn't take into consideration that when using threads, the Perl side of the object wrappers may be cloned, while the C side they point to are not, and so, once some thread calls DESTROY
in any object, the underlaying C structures become deallocated leaving the clones in the rest of the threads with a dangling pointer.
The following post at StackOverflow shows a practical case of that bug being triggered: Perl - How to make a library specific to individual threads.
I have asked in PerlMonks how to solve it: Multi-thread friendly object life-time handling for XS modules.