MAINT: improve C accum error handling #840
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
returning
-1
from a public API C function isn't sufficient to provide useful error information when working in Python/CFFI--it only tells you something went wrong if you check for a return code in the first place (which isn't normally done in Python anyway--normally you end execution at the error point andexit()
with an appropriate error message)when there are multiple conditions that can trigger the
-1
return value, the situation is even worse, one literally has toprintf
sprinkle the source to figure out what went wrong whereas a compromise, I'll leave the
-1
approach in since that is quite common in standardC
, but I'm going to add in prints tostderr
so that Python can then intercept the-1
and refer the user tostderr
also,
darshan_accumulator_inject()
assumed that themodule_id
was reasonable because it was set/checked indarshan_accumulator_create()
, however my experience in ENH: Python derived/accum interface #839 was that the accumulator memory location can get freed, or not properly set at CFFI boundary after calling the creation function, so I think the assumption that a previous function was called and worked perfectly is too fragile--I'm adding error handling to prevent a hard segfault on nonsense values of that structure member as a result