The Mud Connector

Author Topic: D'oh! Boneheaded code/design/build mistakes?  (Read 3904 times)

Hades_Kane

  • Community Manager
  • TMC Veteran
  • *****
  • Posts: 1229
  • Owner / Administrator of End of Time
    • View Profile
    • End of Time
D'oh! Boneheaded code/design/build mistakes?
« on: March 08, 2018, 12:44 PM »
Thought it might be fun to share some anecdotes of things we may have designed, coded, built, that just wasn't working right or had some unintended consequence (memory leaks, filling up the logs, etc.)... or super obvious flaws in your system that once you finally figured it out, it made you feel like an idiot.
-Diablos
End of Time, a 100% free Final Fantasy & Chrono Trigger based MUD with a large original world, unique combat & magic systems, and more!
eotmud.com : 4000 • http://www.eotmud.comhttp://www.facebook.com/eotmud
http://www.mudconnect.com/mud-bin/adv_search.cgi?Mode=MUD&mud=End+of+Time

Hades_Kane

  • Community Manager
  • TMC Veteran
  • *****
  • Posts: 1229
  • Owner / Administrator of End of Time
    • View Profile
    • End of Time
Re: D'oh! Boneheaded code/design/build mistakes?
« Reply #1 on: March 08, 2018, 1:05 PM »
What made me think of this is we've been having some issue with our memory usage steadily going up at a rate that didn't really make sense.

A while back, I tracked the bulk of it down to having port 23 open to connect to the game and the code had no way to close inactive descriptors, so each time a Chinese IP was pinging my host at port 23, it was creating and holding onto a descriptor and never freeing it, so our memory was sky rocketing and our descriptor numbers (ie: the 'sockets' command) was getting well into the hundreds.  I removed the port forwarding in the shell for that and the issue subsided.

I added in Smaug/AFKMud overland image file loading/reading recently, and so I've been keeping an extra eye on our memory usage as a result and I've noticed an uptick in our memory usage so I've been suspicious it was something in that new code, so I went about trying to address that.  Even went so far as to have the maps (aside from the main world map) not load until needed (still need to figure out how to free that memory so I can make it release back if a map hasn't been used in X amount of time and no players are in any areas connected to it)... but there was actually a pretty minor memory usage difference, but I did notice that moving around the map was increasing memory with each movement.

Little bit of digging later, realized that it wasn't movement on just that map, but any movement at all.  Little more experimenting, the look command was doing it.  I turn off prompt... no increase.

Turns out that I had a call to new_buf in the prompt display code without a free_buf in the proper spots... in the piece of code that is probably displayed/called more than almost any other thing in the entire source!  Fixing that and my memory uptick drastically dropped.  Looks like that specific bit of code dates back to September of last year... needless to say, I also combed through my code and found a handful of other spots with similar issues (the who list being one of the other more likely to be called functions with such a leak) and fixed those.  I'm always learning, but this should stick out to me enough to where I'll be far more careful to make sure I free any memory I allocate in the future.

While I was at it, too, I think I solved the issue of descriptors not being freed if the game has been connected to.  I added in a timer value to our descriptor code and if a connection sits on our initial CON_ANSI state for longer than about 20 seconds, it disconnects and frees that descriptor.  This doesn't seem to be exactly fool proof, as occasionally some of our new connections to the game will skip a number or few, but generally there seems to be no more issue with that.  I'm pretty surprised (based on an assumption anyway) that the stock codebases (or at least the Diku branch) never directly addressed idle descriptors that never actually reached the playing connected state.
« Last Edit: March 08, 2018, 1:08 PM by Hades_Kane »
-Diablos
End of Time, a 100% free Final Fantasy & Chrono Trigger based MUD with a large original world, unique combat & magic systems, and more!
eotmud.com : 4000 • http://www.eotmud.comhttp://www.facebook.com/eotmud
http://www.mudconnect.com/mud-bin/adv_search.cgi?Mode=MUD&mud=End+of+Time

Tijer

  • Community Manager
  • TMC Veteran
  • *****
  • Posts: 771
    • View Profile
Re: D'oh! Boneheaded code/design/build mistakes?
« Reply #2 on: March 08, 2018, 2:53 PM »

While I was at it, too, I think I solved the issue of descriptors not being freed if the game has been connected to.  I added in a timer value to our descriptor code and if a connection sits on our initial CON_ANSI state for longer than about 20 seconds, it disconnects and frees that descriptor.  This doesn't seem to be exactly fool proof, as occasionally some of our new connections to the game will skip a number or few, but generally there seems to be no more issue with that.  I'm pretty surprised (based on an assumption anyway) that the stock codebases (or at least the Diku branch) never directly addressed idle descriptors that never actually reached the playing connected state.

Amusingly i am had the same issues as that on my WoL mud... Numerous attempts to make it close descriptor on anything "pre" playing was causing me issues.. :) looked through just about anything that opened files to make sure they were being closed... narrowed it down to idle descriptors.. Took me a while to work that out though :)
« Last Edit: March 08, 2018, 3:53 PM by Tijer »
--Tijer
War of Legend    • Mud • Waroflegend.net port 4200   • Web • http://www.waroflegend.net
Aadarian Realms • Mud • Aadaria.net port 1111/1114  • Web • http://www.aadaria.com

Tijer

  • Community Manager
  • TMC Veteran
  • *****
  • Posts: 771
    • View Profile
Re: D'oh! Boneheaded code/design/build mistakes?
« Reply #3 on: March 08, 2018, 3:56 PM »
I once decided to set up a crontab that as i thought would run a backup script once every seven days.... Little did i know that id set it to make a full backup of the mud every 7 seconds... Left for the night came back to a server that was completely out of disk space, and about 30,000 backups of the MUD!
--Tijer
War of Legend    • Mud • Waroflegend.net port 4200   • Web • http://www.waroflegend.net
Aadarian Realms • Mud • Aadaria.net port 1111/1114  • Web • http://www.aadaria.com

Hades_Kane

  • Community Manager
  • TMC Veteran
  • *****
  • Posts: 1229
  • Owner / Administrator of End of Time
    • View Profile
    • End of Time
Re: D'oh! Boneheaded code/design/build mistakes?
« Reply #4 on: March 08, 2018, 4:11 PM »
I once decided to set up a crontab that as i thought would run a backup script once every seven days.... Little did i know that id set it to make a full backup of the mud every 7 seconds... Left for the night came back to a server that was completely out of disk space, and about 30,000 backups of the MUD!

Lol!

Not exactly the same thing, but I have one setup to backup every night and I used to occasionally forget to clear the backup folder... needless to say a handful of times I'd try to access the MUD and my server was out of diskspace, and I'd actually have to restore a backup after I cleared the folder because there'd be several files that only half wrote to the disk because of being out of space.
-Diablos
End of Time, a 100% free Final Fantasy & Chrono Trigger based MUD with a large original world, unique combat & magic systems, and more!
eotmud.com : 4000 • http://www.eotmud.comhttp://www.facebook.com/eotmud
http://www.mudconnect.com/mud-bin/adv_search.cgi?Mode=MUD&mud=End+of+Time

Drizzt1216

  • Sr. Member
  • ****
  • Posts: 279
    • View Profile
    • tbaMUD
Re: D'oh! Boneheaded code/design/build mistakes?
« Reply #5 on: March 09, 2018, 11:16 AM »
Days, seconds. Close enough. No?

Tijer

  • Community Manager
  • TMC Veteran
  • *****
  • Posts: 771
    • View Profile
Re: D'oh! Boneheaded code/design/build mistakes?
« Reply #6 on: March 09, 2018, 4:41 PM »
at the time i was still learning crontabs.... :)
--Tijer
War of Legend    • Mud • Waroflegend.net port 4200   • Web • http://www.waroflegend.net
Aadarian Realms • Mud • Aadaria.net port 1111/1114  • Web • http://www.aadaria.com

Molly

  • Community Manager
  • TMC Veteran
  • *****
  • Posts: 606
    • View Profile
Re: D'oh! Boneheaded code/design/build mistakes?
« Reply #7 on: March 16, 2018, 4:06 AM »
Our (now retired) coder, who was a bit of a joker, once created a plague that was very contageous, and spread like wildfire among the mobs, who dropped dead like flies. There was also a small chance of players being infected by the mobs, and soon enough that too escalated exponentially, and within a day or so half the playerbase was suffering or dead.

Needless to say, the players did not find it very funny.
Molly O'Hara of 4 Dimensions
4Dimensions.org Port 6000

Hades_Kane

  • Community Manager
  • TMC Veteran
  • *****
  • Posts: 1229
  • Owner / Administrator of End of Time
    • View Profile
    • End of Time
Re: D'oh! Boneheaded code/design/build mistakes?
« Reply #8 on: March 16, 2018, 11:18 AM »
Our (now retired) coder, who was a bit of a joker, once created a plague that was very contageous, and spread like wildfire among the mobs, who dropped dead like flies. There was also a small chance of players being infected by the mobs, and soon enough that too escalated exponentially, and within a day or so half the playerbase was suffering or dead.

Needless to say, the players did not find it very funny.

Lol, that's great.

Reminds me of this old Merc game I used to play called Aargh! MUD (gotta love trying to be first in the alphabetical list, eh?).

There was this player named Quarshak (I'm probably butchering the spelling) and he was notorious for finding and abusing bugs.  Thing about this game was that players weren't really punished for that, they would just eventually close the exploit, but that could be a few days or more before that would happen.  This game also had some measure of randomization in its equipment loading (at least in shops, I don't recall if looted items did as well), and so somehow or another he managed to get ahold of a wand of plague that had a REALLY high spell level, and well, hilarity ensued.  He managed to plague just about every mob in Midgaard, including the recall healer, and so every player that passed through Midgaard or recalled pretty much caught it, and as they moved the plague spread, and so it was at least a week of practically every player and nearly every mob in Midgaard stuck with this.

At some point they put in some healer mobs that was specifically about healing the plague (in retrospec, its a curious decision not to just reboot and put something in to heal people on login if this was a bug/exploit) and encouraging people to avoid Midgaard until it cleared up.  With as annoying as this was in the immediate term, and with as much as a nuisance Quarshak was regarded, after about a day me and a buddy began to see the humor and genius in it, and I'd be fibbing if I said that we didn't, in its later stages, take a couple of purposeful strolls through Midgaard, get infected, and hit up a few other spots in town to help it spread :p
-Diablos
End of Time, a 100% free Final Fantasy & Chrono Trigger based MUD with a large original world, unique combat & magic systems, and more!
eotmud.com : 4000 • http://www.eotmud.comhttp://www.facebook.com/eotmud
http://www.mudconnect.com/mud-bin/adv_search.cgi?Mode=MUD&mud=End+of+Time

Gisco

  • New to TMC
  • *
  • Posts: 26
    • View Profile
Re: D'oh! Boneheaded code/design/build mistakes?
« Reply #9 on: March 16, 2018, 3:00 PM »
A while back, we were stream-lining damage types. One of us took out the old hacky check in the backstab skill and made a function to determine if a given dtype could be used for backstab based on our new damage categories. It was a simple, elegant little piece of code (not mine, FYI), but it had one problem: it returned FALSE when it should have returned TRUE and TRUE instead of FALSE. The new code was booted in and for about a day or so, players could go around backstabbing with anything that was NOT a backstab weapon.

They had a blast.

Whatever you could wield that didn't do backstab damage worked: chairs, barrels, hammers, chains, tree branches, fish, hides, mugs of beer, plates of spaghetti... One of the more memorable logs I remember reading was one person going around backstabbing clowns with a cream pie.
« Last Edit: March 16, 2018, 3:49 PM by Gisco »

Hades_Kane

  • Community Manager
  • TMC Veteran
  • *****
  • Posts: 1229
  • Owner / Administrator of End of Time
    • View Profile
    • End of Time
Re: D'oh! Boneheaded code/design/build mistakes?
« Reply #10 on: March 16, 2018, 3:07 PM »
A while back, we were stream-lining damage types. One of us took out the old hacky checkOne of the more memorable logs I remember reading was one person going around backstabbing clowns with a cream pie.

-Diablos
End of Time, a 100% free Final Fantasy & Chrono Trigger based MUD with a large original world, unique combat & magic systems, and more!
eotmud.com : 4000 • http://www.eotmud.comhttp://www.facebook.com/eotmud
http://www.mudconnect.com/mud-bin/adv_search.cgi?Mode=MUD&mud=End+of+Time

vosie

  • New to TMC
  • *
  • Posts: 3
    • View Profile
Re: D'oh! Boneheaded code/design/build mistakes?
« Reply #11 on: April 23, 2018, 1:23 AM »
For me, it's that I never know when to stop building until I'm oh... about 300 rooms too big.