Generally the 'attempt to free unrerefenced scalar' error is an
indication of a bug in perl (or XS code). Threads in early versions of 5.8.x are well-known for these sorts of problems.
Try upgrading to something newer (preferably 5.8.6) and see if the problem goes away.