Wednesday, October 31, 2012

Case of drop-down #2147483647

It began when our QA server had stopped responding to any requests. So it did for pings. Virtual machine console shown that the server was still running, and that was weird. We explicitly restarted it and started investigation.

    It looked like a disaster, really. There are no crash dumps, log files, etc. It just stopped working. So we decided to wait the situation to reoccur.

   And it did occur again in about 10 minutes: w3wp.exe process started to consume memory with the eagerness no one could imagine and explain: during a minute memory usage had increased from 300Mb to 1.2Gb and continued to increase. That was good news from a certain point of view - we had reproduced that strange situation. But from the other side, we couldn't do a lot because computer became pretty unresponsive.

   Attempt to create crash dump using Process explorer or Task manager failed with a strange message:

Only part of a ReadProcessMemory or WriteProcessMemory 
request was completed.

    Windbg shown that there were about a 1M objects of SelectListItem objects. That is not something that we meet everyday. But that was obvious that the application tried to create long select list - but the question was why.

   After some investigation we found an answer. The problem had been caused by a form, where new tasks (for students) had been entered. There was a "Max mark" field, with default value 10, which specified maximum mark value for a particular task.


An author of functionality didn't know if there should be an upper limit for this "Max mark", so, logically, he set it to Int32.MaxValue. And, logically, during testing QA person saw a validation message that Max mark "Must be between 1 and 2147483647". And... entered 2147483647. Why, of course she should have entered that..

  To simplify marks entering, all allowed values are represented as a drop-down list from 0 to maximum value - and here the application tried to generate a drop-down list with 2147483647 items, consuming up to 2Gb of memory.

  Although it's easy to fix, that was an interesting experience.







No comments:

Post a Comment