Avoid iloop externalizing diagnostics for invalid references #1028
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.
What
Don't store Vals with broken object references in the diagnostic event log.
Why
This avoids an infinite loop / recursion. There may be better solutions.
This is a followup to stellar/rs-soroban-sdk#1068 where I was experimenting with feeding the Env objects with invalid references.
The Host has a
check_val_integrity
function that is called on every Val it sees in order to prevent bad Vals from entering the environment, in particular it errors when it sees objects with broken references.This function ends up calling
visit_obj_untyped
. When that function fails to find an object body it returns thisWhen diagnostics are on, the effect of this is to log an "unknown object reference" event that contains the broken object, then immediately generate an error; while generating that error it attempts to externalize the diagnostic it just logged;
that diagnostic contains a broken object, and while externalizing it will generate more errors, etc. forever.
It is not clear to me why this doesn't smash the stack, but instead iloops (maybe the XDR DepthLimiter is helping). Here is a ~3k frame backtrace captured in gdb: https://gist.github.com/brson/aa2799208123895316228ca0cb425317
Known limitations