Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix server crashing on Lua errors #3305

Closed
wants to merge 1 commit into from

Conversation

ShadowNinja
Copy link
Member

Previously, the server called FATAL_ERROR when a Lua error occured.
This caused a (mostly useless) core dump, and, in servers running managed in gdb, a similarly useless and confusing backtrace.
The server now simply throws an exception, which is caught and printed before exiting with a non-zero return value.
This also fixes a number of instances where errors were logged multiple times (as many as three times).

Fixes #3213 (which was also reported by VanessaE).

Implementation note: I changed loadMod and loadScript from returning a bool and taking a error argument to just throwing an exception on error. This made things easier since the error message was often just turned into an exception and thrown.

Previously, the server called FATAL_ERROR when a Lua error occured.
This caused a (mostly useless) core dump.
The server now simply throws an exception, which is caught and printed before
exiting with a non-zero return value.
This also fixes a number of instances where errors were logged multiple times.
@ShadowNinja ShadowNinja added Bug Issues that were confirmed to be a bug @ Script API Medium priority labels Oct 29, 2015
@nerzhul
Copy link
Member

nerzhul commented Oct 29, 2015

👍

const ModSpec &mod = *i;
for (std::vector<ModSpec>::iterator it = m_mods.begin();
it != m_mods.end(); ++it) {
const ModSpec &mod = *it;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has nothing to do with what the PR does. What's bad about i? Is it only reserved for integers?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iterators aren't something spooky, only because their incrementation operation is slightly more complex.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer it because i is traditionaly an abbreviation for integer. This doesn't really matter much though, I wouldn't mind removing it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I'm ok if you want to keep it in.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i is traditionally an abbreviation for integer? Way back in 1994 we were using 'i' because we believed it was an abbreviation for iterator :/ :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it or iter for iterators because it's immediately clear that the variable is an iterator. I approve of this change too.

Really, I like anything that makes the code clearer.

@est31
Copy link
Contributor

est31 commented Oct 30, 2015

Otherwise, it looks good, but we have to take care that nothing gets deinitialized when ServerError gets thrown. But I have no problem with putting the code on master and waiting for error reports.

@kwolekr
Copy link
Contributor

kwolekr commented Oct 31, 2015

So just to recap what went on in this PR:

  • ModError was moved to exceptions.h with the other exceptions (sounds good to me)
  • LuaError was made into a ModError, and ModError is now a BaseException (neutral)
    • For this one, please make CERTAIN that LuaErrors are all being caught as they're supposed to. This means checking all previous instances of ServerError and ensuring ModError is caught as well, or at least that you intended for this behavior to happen.
  • loadScript/loadMod/etc. were modified to throw exceptions instead of return a boolean success/failure, which makes handling of script load failures uniform with script execution failures (sounds good to me)
  • Some minor code style fixes along the way (sounds good to me, but sort of distract from the main goal of the PR making things harder to track and review)

Overall, 59 lines were added and 81 removed, while increasing organization. Sounds like a success as long as it doesn't introduce any new bugs.

@ShadowNinja
Copy link
Member Author

Yep, that's basically all other than adding a try/catch to handle those exceptions.
I did check, and everything that handled ServerErrors also handles ModErrors.

@kwolekr
Copy link
Contributor

kwolekr commented Oct 31, 2015

Okay then, 👍

@ShadowNinja
Copy link
Member Author

9269a0e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues that were confirmed to be a bug @ Script API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Server crash on Ubuntu 15.04
5 participants