Yul: dump source/target stacks when findStackTooDeep aborts#16705
Open
msooseth wants to merge 1 commit into
Open
Yul: dump source/target stacks when findStackTooDeep aborts#16705msooseth wants to merge 1 commit into
msooseth wants to merge 1 commit into
Conversation
Add an opt-in debug dump for the case described in argotorg#16704: when `findStackTooDeep` propagates a `YulAssertion` from `createStackLayout` (e.g. "Could not create stack layout after 1000 iterations"), the source and target stacks at that point are otherwise opaque to anyone debugging from a user-supplied .sol reproducer. When the environment variable `YUL_DEBUG_DUMP_SHUFFLE_FAILURE` is set to a non-empty value, the source and target stacks (rendered via the existing `stackToString(Stack, Dialect)` helper) are printed to stderr in the StackShufflingTest `.stack` format (see test/libyul/yulStackShuffling/*.stack), so the failing input can be dropped into the test suite verbatim. Example: // findStackTooDeep aborted (source.size=1, target.size=1237) [ RET ] [ RET RET[fun_double_27] RET[fun_double_27] ... ] // ==== // maximumStackDepth: 16 Mechanically: * `findStackTooDeep` gains a `Dialect const&` parameter (needed by `stackToString` for resolving function names in `RET[...]` / `TMP[...]` slots). All four call sites already have `m_evmDialect` available and pass it through. * The `::createStackLayout` invocation is wrapped in a `try` / `catch (YulAssertion const&)` that does the conditional stderr print and then `throw;`s -- so when the env var is unset, behavior is byte-identical to before. No Changelog entry: this is a developer-only debug aid and doesn't change any user-visible behavior.
d4b4c10 to
11214b1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add an opt-in debug dump for the case described in #16704: when
findStackTooDeeppropagates aYulAssertionfromcreateStackLayout(e.g. "Could not create stack layout after 1000 iterations"), the source and target stacks at that point are otherwise opaque to anyone debugging from a user-supplied.solreproducer.When the environment variable
YUL_DEBUG_DUMP_SHUFFLE_FAILUREis set to a non-empty value, the source and target stacks (rendered via the existingstackToString(Stack, Dialect)helper) are printed to stderr in theStackShufflingTest.stackformat (seetest/libyul/yulStackShuffling/*.stack), so the failing input can be dropped into the test suite verbatim. Example:Mechanically:
findStackTooDeepgains aDialect const¶meter (needed bystackToStringfor resolving function names inRET[...]/TMP[...]slots). All four call sites already havem_evmDialectavailable and pass it through.::createStackLayoutinvocation is wrapped in atry/catch (YulAssertion const&)that does the conditional stderr print and thenthrow;s — so when the env var is unset, behavior is byte-identical to before.No Changelog entry: this is a developer-only debug aid and doesn't change any user-visible behavior.
Refs #16704.