views:

1773

answers:

5

While running a perl program I encountered the following error

*** glibc detected *** perl: double free or corruption (!prev): 0x0c2b7138 ***
/lib/tls/i686/cmov/libc.so.6[0xb7daea85]
/lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb7db24f0]
perl(Perl_pregfree+0x3e)[0x80a004e]
perl(perl_destruct+0xcf1)[0x806b711]
/usr/local/lib/perl/5.8.8/auto/threads/threads.so[0xb79d2dfb]
/usr/local/lib/perl/5.8.8/auto/threads/threads.so[0xb79d2f9b]
/usr/local/lib/perl/5.8.8/auto/threads/threads.so[0xb79d5fbb]
/lib/tls/i686/cmov/libpthread.so.0[0xb7e974fb]
/lib/tls/i686/cmov/libc.so.6(clone+0x5e)[0xb7e19e5e]

My OS is Ubuntu 8.04, Perl version is 5.8.8

My scripts contains threads ... I cannot share the code but wanted to know if anyone has had experience with this type of errors and how you had resolved/approached/analysed it. Are there any tools/logs that i could refer to inaddition to work on this sort of issues.

Thank you for your support.

P.S: I know that threads are not the ideal friends for anyone. However I do not control decision of using perl. I am just maintaining the code.

+1  A: 

The most likely cause is an incompatible version of glibc. You need to run Perl with the version of glibc with which it was compiled

dsm
i am using perl installed with ubuntu. I believe that the perl installed by default should compatible with the glibc version.Plus I have experienced the same problem on RHEL5 too. So it should nto be that both these systems could have version conflict.
Neer
+1  A: 

This looks like an error internal to Perl. The "double free or corruption" refers to memory being freed twice, or corrupted. Perl manages memory for you, so this should never happen if Perl is working correctly.

Is there a newer version of Perl you can upgrade to?

Kevin Beck
I am using perl 5.8.8 ... I can upgrade to 5.8.8 however the product that i am working is supported only on 5.8.8. Are there any other tools that I could hook up to the the debugger and monitor the actions and can pin point exactly at what point the script broke.
Neer
Personally, I would try upgrading to 5.8.9. It is supposed to be a maintenance release, so is unlikely to break your application.The release announcement for Perl 5.8.9 does mention a fix for a threadsafe issue. This could be exactly your problem.http://search.cpan.org/~nwclark/perl-5.8.9/pod/perl589delta.pod#Smaller_fixesIn theory, you could attach a debugger to Perl and try to learn more about where the problem is. This would be very ambitious.
Kevin Beck
+2  A: 

This thread on the perl5 porters mailing list seems to indicate that it's a known problem with 5.8.8 and threads. I think your problem is probably due to a code problem that isn't caught by perl.

If you can, I would suggest stripping down the code to a minimal example. You should then be able to attempt to fix the code problem.

Nic Gibson
Stripping down the code is looking for a hefty task. I want to do it as a last resort. Do we have any visualisation tools for perl threads. Or am i being too ambitious???
Neer
http://delta.tigris.org is a good tool for creating a minimal reproducible test case. It shouldn't be a hefty task with the proper mechanical help :)
ephemient
Following on similar threads as newt had pointed found that this is a known issue and will be covered in the future versions. I replaced the section where I doubted the issue was in with an alternate hack .. Works good .. Thanks for the pointer...
Neer
+1  A: 

open your code and put in it somewhere before where the problem occurs:

$DB::single=1;

Then run

PERL5OPT='-dt'  perl yourscript.pl

and hit

c[enter]

repeatedly until the problem recurs. ( Keeping note of whether it stops at your manual breakpoint or not before failing ).

Then iteratively move the manual breakpoint forward/back until you have it just before your termination point ( you could find the death point with a bunch of print commands also ), and then try work from there, possibly with pre-crash introspection.

This will (hopefully) help you generate a test-case which exhibits the problem.

Kent Fredric
Braking into threads was getting a lot of headache for me .. Thanks for this info. :) This is how I could actually find out what the problem was. Just did not comeback and tag your solution.
Neer
A: 

Try updating 'threads' and 'threads::shared' modules from CPAN.

Alexandr Ciornii