-
Notifications
You must be signed in to change notification settings - Fork 53
Parsing logic: fail gracefully on unexpected input #1237
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
Conversation
| std::cerr << "WARNING: Skipping invalid openPMD record '" | ||
| << record_name << "'" << std::endl; | ||
| while (!IOHandler()->m_work.empty()) | ||
| IOHandler()->m_work.pop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to clear the queue here anymore, it's already cleared by AbstractIOHandler::flush() upon failure
5a5275f to
83dd2ad
Compare
src/Iteration.cpp
Outdated
| std::make_optional<DeferredParseAccess>(std::move(dr)); | ||
| } | ||
|
|
||
| void Iteration::read() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged this with runDeferredParseAccess, no reason to keep them separate.
| { | ||
| *newType = oldType; | ||
| throw; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This style of try-catch-block is necessary if we want to keep the Series usable after throwing an exception. If we want to avoid this, we must find a way to parse without changing that state.
0795431 to
2ed1ba2
Compare
|
(not actually ready for review, just wanting to run the CI) |
8886071 to
1a6b89c
Compare
|
This pull request introduces 1 alert when merging 1985a70 into 3c57afb - view on LGTM.com new alerts:
|
4e2719e to
e4e00b3
Compare
|
This pull request introduces 1 alert when merging e4e00b3 into 8b4a58a - view on LGTM.com new alerts:
|
The most important pattern I have it reading a series (any encoding) from a sim that is currently running. The latest time step is usually incomplete. |
ec9defd to
91eed89
Compare
|
This pull request introduces 1 alert when merging 91eed89 into 29bb474 - view on LGTM.com new alerts:
|
91eed89 to
0213774
Compare
|
This pull request introduces 1 alert when merging 124b923 into 29bb474 - view on LGTM.com new alerts:
|
124b923 to
2397323
Compare
|
This pull request introduces 1 alert when merging 47ec995 into 9c4173a - view on LGTM.com new alerts:
|
47ec995 to
20e1cf4
Compare
|
This pull request introduces 1 alert when merging b64988f into 9c4173a - view on LGTM.com new alerts:
|
2117261 to
bf43dbe
Compare
bf43dbe to
6d08b14
Compare
|
Thanks a lot! I did a first test reading partially written simulation data, i.e., the |
|
This is the output that I get upon Weirdly enough, the segfault only appears when redirecting stderr into a file.... update: we use |
ax3l
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great!
Added inline comments :)
| message(WARNING "Invasive tests that redefine class signatures are " | ||
| "known to fail on Windows!") | ||
| endif() | ||
| target_compile_definitions(openPMD PRIVATE openPMD_USE_INVASIVE_TESTS=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This macro should never be shipped. It introduces UB and is only used in some testing.
| target_compile_definitions(openPMD PRIVATE openPMD_USE_INVASIVE_TESTS=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The macro is still activated only in those special tests and not shipped (see the if(openPMD_USE_INVASIVE_TESTS) above). I need this macro inside Iteration.cpp in here:
Line 542 in 8c0d2a2
| #ifdef openPMD_USE_INVASIVE_TESTS |
This is the most reliable way to trigger errors to be thrown.
Are there workflows where users compile openPMD with openPMD_USE_INVASIVE_TESTS and still install the resulting compiled library? If yes, are there better ways to do this then?
Just removing this line breaks the parsing test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I see.
ok, extents its meaning but is ok.
Some weird compiler configurations don't understand error type symbols across libraries, so keep the symbols entirely to the main library.
This is the commit with the most complicated logic changes. It implements skipping broken iterations at the Series level. This includes the Streaming API (Series::readIterations()), as well as our three iteration encodings. On the positive side: The most complex logic changes have already been prepared in the topic-adios2-append PR
Nothing too complicated, just tedious
`using no_such_file_error = error::ReadError` for backwards compatibility in user code.
@todo: Check if this needs to be done elsewhere
f74b697 to
5026e21
Compare
ax3l
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 ✨
Reading failures should ideally affect only the innermost scope possible. When one record component fails parsing due to whatever error, the neighboring record components should remain readable. When one iteration fails parsing, skip it and go on to the next.
Current behavior: Parsing fails and the Series cannot be opened
Close #983
TODO
ReadErrorerror type that backends can throw to tell the frontend about recoverable failuresReadErrorinside ADIOS1 and ADIOS2 attribute reading routinesReadErrors(partially implemented so far)Other backends,also consider dataset reading, ... UPDATE: Catching wrong attribute reads now possible in all backends, dataset reading and further things can come in a later updatefile-based, group-based, varialbe-based, deferred/eager, opening single iterations of a file-based series,streaming API, skipping iterationbp4_steps test seems to not write snapshot attributeonly written in new ADIOS2 schema as it should beThis whole PR is a bit of a stretch-goal as there are many different types and sources of errors to be recovered from.
@ax3l Can you name some specific error pattern (or even give me a test file) that the openPMD-api should handle more robustly?
I think that a backend failure should mean that the entire call to
AbstractIOHandler::flush()has failed and the queue is cleared. For finer granularity error handling, the frontend must issue singleflush()calls. So, I've changed error recovery procedures to clear the entire IO queue upon failure.