-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
print tracebacks and line numbers for Lua runtime errors #6564
print tracebacks and line numbers for Lua runtime errors #6564
Conversation
Not sure I fully get it, but we 100% control profile API versions, i.e. we won't have any bump of profile API version until we will do that on our own, so I think we can just go with this risk that in the future we may forget to update those switches, but I hope in this case some compiler warning or sanitizer check should catch it. Btw why we have those switches is just because we have to be backward compatible with all old versions of Lua profiles.
As I can see both Let me please know if you need more help here :) |
08f6eef
to
974b777
Compare
@SiarheiFedartsou I think this is ready to go! I added unit tests, backed out the changes for those functions we weren't sure about, and confirmed that an error on any lua thread shuts OSRM down entirely. I don't see any wiki pages that would be affected by this change, so haven't made any updates there. |
Thanks @mattwigway ! |
@mattwigway |
974b777
to
6abc896
Compare
Ah, clang-format-10 is the piece I was missing before. Rebased and formatted. |
@mattwigway you are probably missing |
Oops, I meant to delete the function that uses fstream as it's from an earlier way I tried to specify the test. Will fix. |
@SiarheiFedartsou I think this should be fixed now. |
I'm not sure what the memory leak test is flagging. I'll investigate later this week. |
Yeah, would be nice, usually it does not have false positives, but taking into account use case(it happens only on error and we exit program anyway) I think we can just suppress it if we won’t find a reason or it will be too complicated to fix. Also I was going to look on my own, but I think I will be able to do that only on the next week in the best case. |
I think what's going on here is that when process_way crashes and the traceback is printed, the way that it's currently processing never gets freed. This would have happened before, and the only reason it's showing up now is that there is now a test of bad code fed to the extractor. Normally the exception shuts down the whole OSRM process so it doesn't matter as you say, but in the test we catch the exception to make sure the exception handling worked. So I think suppressing the warning is probably appropriate, as it won't be an issue in production. |
@mattwigway then I think you can configure it somewhere here
AFAIR this file follows syntax described in https://clang.llvm.org/docs/SanitizerSpecialCaseList.html, so you can suppress this specific issue. |
When the extractor encounters a lua runtime error, some osmium objects are not freed. In production this doesn't matter because these errors bring down OSRM. In the tests we catch them to ensure they occur, and the leaksanitizer flags them.
29c87c9
to
2cf3e70
Compare
@SiarheiFedartsou looks like that change fixed it. I rebased from master, LMK if anything else is needed. |
@mattwigway many thanks for this contribution and I will be happy to review any other PRs from you 👍 |
…M#6564) * print tracebacks and line numbers for Lua runtime errors * revert format changes * update changelog with lua traceback, Project-OSRM#6564 * revert using protected_function for old GetStringListFromFunction and source_function Project-OSRM#6564 * add unit test for line numbers in tracebacks, Project-OSRM#6564 * apply clang-format (Project-OSRM#6564) * remove unused test helper function, Project-OSRM#6564 * suppress leaksanitizer warnings in extract-tests, Project-OSRM#6564 When the extractor encounters a lua runtime error, some osmium objects are not freed. In production this doesn't matter because these errors bring down OSRM. In the tests we catch them to ensure they occur, and the leaksanitizer flags them.
…M#6564) * print tracebacks and line numbers for Lua runtime errors * revert format changes * update changelog with lua traceback, Project-OSRM#6564 * revert using protected_function for old GetStringListFromFunction and source_function Project-OSRM#6564 * add unit test for line numbers in tracebacks, Project-OSRM#6564 * apply clang-format (Project-OSRM#6564) * remove unused test helper function, Project-OSRM#6564 * suppress leaksanitizer warnings in extract-tests, Project-OSRM#6564 When the extractor encounters a lua runtime error, some osmium objects are not freed. In production this doesn't matter because these errors bring down OSRM. In the tests we catch them to ensure they occur, and the leaksanitizer flags them.
Issue
This fixes #6563, and provides tracebacks and line number for Lua runtime errors. It does this by replacing all
sol::function
s withsol::protected_function
and checking for errors after a Lua function is called. If one is detected, a traceback is printed to stderr, and an exception is thrown which causes OSRM to exit (as it did before when runtime errors were encountered).Before:
After:
I believe the error message is printed multiple times because the error is getting hit in multiple threads before the exception kills the entire process. My understanding is that a single exception should kill the entire process, not just the thread, but I'm new to C++ so if that's incorrect changes will be required to ensure runtime errors actually terminate extraction.
Performance impact is negligible/nonexistent. With my small test PBF file, it took 3.511s to build and partition with this patch and 3.563 without.
I ran thewent ahead and reverted these for ease of review.format.sh
script as requested and it made some format changes elsewhere in the files. If this is an issue I can go back and manually revert those changes. It doesn't seem to pollute the diff too much.Tasklist
I'm new to C++ and contributing to OSRM, so there's a few things I'm not completely sure of and would love feedback on.
source_function
andGetStringListFromFunction
do. I changed these to have Lua error handling but it I'm not sure how to test them.Requirements / Relations
N/A