Vladimir Prus


vladimirprus.com

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.

8 comments:

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

Anonymous said...

mobile app development developers always foster to make good relationships with our potential clients.

Anonymous said...

With our advanced web application penetration testing services, we help you detect cyber threats and combat against it

Anonymous said...

We offer custom shopify app development exceptional services at budget friendly rates without any hassle

Anonymous said...

time tracking tool Use Time Logger as a time tracker on web and mobile (iOS & Android) or through the slack integration

MCGREGOR VS POIRIER 2 said...

Thanks for all of your time & work.

Anonymous said...

We can be called your problem solvers; every academic problem that you come across, we are there to listen no matter how difficult or how timely Get Assignment Done Online it is, we can arrange the best possible solutions for you. So it is only win and win for you, if you plan to hire us for your assignments.