Vladimir Prus


Tuesday, April 04, 2006

Unlucky numbers: 48, 58 and 388

One day I've got a remarkable bug report:
We're calling the function from your library, and after 48 successfull calls, it crashes. Can you look into this?
Initially, I was curious how did they count that '48'. It turned out that the application was repatedly doing the same action, calling my code alogn the way, and counting the number of repeatitions, so '48' was the exact number, and the thing conistently crashed after 48 calls.

The bug report did not include any calling code, so I've asked for the code to be sent, and went home, and while in a bus decided that either it's fixed size buffer in the calling code, or resource leak, like file descriptors leak.

And sure thing, next morning I looked at the only thing where I used plain FILE* in order to use Bison-based parser, and there was missing fclose call. Feeling rather smart, I've sent the fixed version back.

After 30 minutes new bug report arrived saying that the code fails after 58 calls. And this time, the bug does not reproduces for me. After several tries I found out that for me, the unlucky number is actually 388, so I need to wait a bit to reproduce the bug.

This was resource leak too, though a subtle one. The library was calling external tool, and modified the PATH environment to make sure the tool is found. As the result, the length of PATH variable steadily increased, and finally some OS limit would be reached. After that the value of PATH becomes completely bogus and the external tool won't be found.

I'm really glad we have Valgrind so at least memory leaks don't require any magic to debug.


mariamith said...

Anyone can attempt writing on your behalf, however, the question is would you pay someone to do it for you without checking their credibility? Our firm has established itself as the most trustworthy assignment help firm in Australia and globally. Join these thousands of students and achieve high distinction in each and every one of your college tasks. This is the main reason why most students search for assignment help australia over the internet and choose only the most proficient and trusted academic writing experts. So, if you are searching for quality usa assignment help you can find it right here from the local experts.

Qasim Khan said...

Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Essay Writer Online Uk

Anonymous said...

This is extremely helpful info!! Very good work. Everything is very interesting to learn and easy to understand. Thank you for giving information. Men Fashion Brown Leather Long Coat