I have the unfortunate task of maintaining an orphaned Perl program that uses Perl/TK to create a GUI and crashes in some situations with errors like
*** glibc detected *** /usr/bin/perl: corrupted double-linked list: 0x0000000003daf500 ***
Is it basically possible for a Perl program to contain a bug that causes such behaviour or can I safely assume that a bug in the Perl interpreter and/or Perl/Tk is responsible and waiting for a new version of those tools might be the best approach to get rid of this problem?
EDIT: To make my question more clear: would a bug like attempting to destroy a widget twice or calling a method on an already destroyed widget result in a clean error message or could it cause the problems I’m experiencing?
EDIT2: The Perl version is 5.10.0/x86_64-linux-thread-multi
And it uses this modules:
use Tie::Watch;
use Tk;
use Tk::Balloon;
use Tk::Compound;
use Tk::DialogBox;
use Tk::LabFrame;
use Tk::NoteBook;
use Tk::Pane;
use Tk::ROText;
use DBI;
use Data::Dumper;
use XML::Simple::DTDReader;
Yes, it is possible but in this case unlikely.
There are multiple ways to directly access (and modify) program memory in Perl (and for that matter, any programming language). There are extensions for this (Win32::Process::Memory for Windows), but under Linux the easiest way would be to open /proc/pid/map (process memory, mapped to a random-access file) and manipulate that.
So, definitely possible.
It is however very unlikely that your Perl program is using any of these tricks to manipulate its own memory directly. As you thought, the most likely culprit is one of the libraries used (Tk in this case).
You could try to use Devel::Trace module to see what the program is trying to do just before its crashes.
If you can find that it is always crashing on a particular line, you could try to alter its behavior to avoid triggering the bug in underlying libraries. That’s a bit of hit-and-miss affair, though.
If someone has knowledge of this kind of bug in Perl/Tk that could be helpful. Is your program using other libraries using C libraries (e.g. not “pure perl” libraries) than Tk?