Saturday, May 16, 2009

On the 6th of the season, I found the divide-by-zero

For the last week, Evidyon has been plagued by an "integer divide-by-zero" error that crashed the server several times a day.  A perfect example of a Heisenbug, it occurred after a seemingly random amount of time, never on my test code and nobody knew what was causing it.  I had the insight to install MSVC++ 2008 Express on the server, transfer over the PDB and catch the error the next time it occurred.  The first couple of times the error looked like it was coming from the enet_host_service method, but the stack was all messed up and it just didn't seem like a logical place for the errror to occur.  This morning, however, I attached the debugger in a different way (attach to the process when it created the exception, then hit "break all", then OK on the dialog) and it took me into the melee combat controller.  A few updates back I changed how characters calculate their damage, and apparently some had a zero range--so when damage = base_damage + rand()%damage_range was invoked, damage_range was sometimes zero and a modulus by zero invokes a divide-by-zero exception.  Bam!

1pm
Changed the view perspective.  It's MUCH better looking now.  Also added day/night lighting effects--nothing fancy, though.  Update went fairly smoothly.  The EXE was corrupted in the upload though and something weird happened.  Recompiling fixed it.

2pm
Another problem has reared its ugly head: melee damage is fuxed.  Players are doing far less per hit than they should be.  I'm going to work on this after bazaar, since it deals with armor/weapon damages/etc.  They're all linked.

4pm
Coded EvidyonGUIActionButtonList, EvidyonGUIModule_BazaarCategories, EvidyonGUIModule_BazaarCategoryItems and EvidyonGUIModule_Bazaar.  Added actions to the UserActionQueue, fixed a minor oversight with the tell-items network message.  *phew* coding UI is tedious.  Going to get through it though.

5pm
I didn't fix the error.  Stupid % not being dominant.

No comments: