This is a weblog I'm keeping about my work on Debian and any other useful Debian related info I come across. It is not meant to compete with other news sources like Debian Weekly News or Debian Planet. Mostly it is just a way for me to classify and remember all the random bits of information that I have floating around me. I thought maybe by using a blog it could be of some use to others too. Btw. "I" refers to Jaldhar H. Vyas, Debian developer for over 8 years. If you want to know more about me, my home page is here.
The name? Debain is a very common misspelling of Debian and la salle de bains means bathroom in French.
If you have a comment to make on something you read here, feel free to write to me at email@example.com.
You can get an rss 0.91 feed of the blog here.
Aaargh gcc 5.x You Suck
==37698== HEAP SUMMARY: ==37698== in use at exit: 72,704 bytes in 1 blocks ==37698== total heap usage: 5 allocs, 4 frees, 84,655 bytes allocated ==37698== ==37698== LEAK SUMMARY: ==37698== definitely lost: 0 bytes in 0 blocks ==37698== indirectly lost: 0 bytes in 0 blocks ==37698== possibly lost: 0 bytes in 0 blocks ==37698== still reachable: 72,704 bytes in 1 blocks ==37698== suppressed: 0 bytes in 0 blocks
One of things I've learnt which I've been trying to apply more rigorously is to avoid manual memory management (news/deletes.) as much as possible in favor of modern c++ features such as std::unique_ptr etc. By my estimation there should only be three places in my code where memory is allocated and none of them should leak. Where do the others come from? And why is there a missing free (or delete.) Now the good news is that valgrind is saying that the memory is not technically leaking. It is still reachable at exit but that's ok because the OS will reclaim it. But this program will run a lot and I think it could still lead to problems over time such as memory fragmentation so I wanted to understand what was going on. Not to mention the bad aesthetics of it.
My first assumption (one which has served me well over the years) was to assume that I had screwed up somewhere. Or perhaps it could some behind the scenes compiler magic. It turned out to be the latter -- sort of as I found out only after two hours of jiggling code in different ways and googling for clues. That's when I found this Stack Overflow question which suggests that it is either a valgrind or compiler bug. The answer specifically mentions gcc 5.1. I was using Ubuntu LTS which has gcc 5.4 so I have just gone ahead and assumed all 5.x versions of gcc have this problem. Sure enough, compiling the same program on Debian stable which has gcc 4.9 gave this...
==6045== ==6045== HEAP SUMMARY: ==6045== in use at exit: 0 bytes in 0 blocks ==6045== total heap usage: 3 allocs, 3 frees, 10,967 bytes allocated ==6045== ==6045== All heap blocks were freed -- no leaks are possible ==6045==
...Much better. The executable was substantially smaller too. The time was not a total loss however. I learned that valgrind is pronounced val-grinned (it's from Norse mythology.) not val-grind as I had thought. So I have that going for me which is nice.