fix: ExchangeSession.UnmarshalJSON infinite recursion#2
Closed
rs-assistant wants to merge 1 commit into
Closed
Conversation
ExchangeSession.UnmarshalJSON calls json.Unmarshal(data, session), which dispatches back to UnmarshalJSON, causing infinite recursion and a fatal stack overflow at runtime. Use a type alias to break the recursion so json.Unmarshal uses the default decoder instead of calling UnmarshalJSON again. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
Author
|
Retargeting to upstream c9s/bbgo. |
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.
Summary
ExchangeSession.UnmarshalJSONcallsjson.Unmarshal(data, session)which dispatches back toUnmarshalJSON, causing infinite recursion and a fatal stack overflow at runtime.exchangeSessionAlias) to break the recursion chain, sojson.Unmarshaluses the default decoder.Root cause
Commit
844601fe4introduced theUnmarshalJSONmethod. The second unmarshal call passessession(a*ExchangeSession) directly, which triggers the customUnmarshalJSONagain — infinite loop.How it was found
The optimizer (
bbgo optimize) crashes withfatal error: stack overflowwhen parsing YAML configs containing exchange session definitions.Test plan
bbgo-slim optimizecompletes without stack overflow after fixbbgo-slim backtestruns correctly with the fix🤖 Generated with Claude Code