in reply to GDB journey into perl internals

As they said in the movie, “Zed, we've got a bug! Simple as that. Thank goodness you found it.

What you're basically looking at is a “double free,” and it is occurring when Perl is leaving the scope of a function or block. The target variable, which is at a known location in your Perl program (“line xyz”) must be the culprit. The error, though it may be difficult to find, is legitimate. It won't go away.

Look carefully at your XS code and see how you're handling memory and reference-counting within your own code. Maybe insert some debugging statements when you release memory. If you're using a compiler that provides its own garbage collection, make sure you know how that works.

Most importantly of all, when you release anything, always explicitly set every pointer to that thing to NULL and do it in the very next statement! (Failure to do that, albeit in vendor-supplied code, once cost me $10,000.00 in real money, but that's another story.)

The problem isn't in “Perl internals.” It is, I'm sorry to say, entirely and directly in your code. Definitely a b**ch to find...