Python MySQL junk pointer not making sense

(There’s got to be a name for blog posts that you make just so you’ll be able to remember something later – or so somebody who is banging their head against a problem you just solved can find your solution via Google magic. This is one of those posts.)

A while back I started getting bizarre errors when using Python with MySQL. They looked like this:

python in free(): warning: junk pointer, too high to make sense

It didn’t make sense to me either! Tech support for my VPS and copious Google searching didn’t turn up anything I could use.

Because most of the sites on this server are now using SQLite instead of MySQL, this wasn’t a particularly critical problem – especially since the front-ends continued to work fine for the most part.

The likely culprits were, of course: Python, MySQL, or the glue holding them together (the MySQLdb extension). All three were at the latest versions available via FreeBSD ports, and I stick with ports unless absolutely compelled to do otherwise. And other stuff on the server depended on MySQL or Python separately, so I was reluctant to mess with them. There I sat.

Today it occurred to me that it would be a cheap experiment to force a reinstall of the least critical of the three, MySQLdb. So:

sudo portupgrade --force databases/py-MySQLdb

And that was it. Everything works dandy now.

Tim Keating commented on Thu Oct 19 15:52:05 2006:

There is something like that. It’s called a “bookmark”.


Matt Rose commented on Thu Oct 19 19:14:31 2006:

Yeah, but then nobody else gets to benefit from your revelation. I have a blog entry from 2001 that still gets hits when somebody wants to run an IMAP server without TLS on debian. Plus, when you put it on your blog, you know where to find it.

Morris commented on Fri Dec 29 23:48:15 2006:

I would guess that this is a warning that a pointer has been corrupted. A pointer to memory above allocated memory is a bad pointer, which is detected when free() is called, and that is probably what “too high to make sense” means. A search on that phrase finds the same error for httpd, awk, perl, gdb so it is probably a message from the kernel (BSD?).

Of course, working out what is causing memory corruption is often painful. The upgrade may have had a fix, or it may have just moved the corruption so that it no longer affected you ;)