Skip to content
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

remove VoteState::deserialize() from sbf builds #30515

Merged
merged 1 commit into from
Feb 26, 2023

Conversation

2501babe
Copy link
Member

Problem

the existing VoteState::deserialize implementation overruns the sbf stack and is unusable in a program context. unfortunately, all programs that import solana_program receive a stack size violation warning due to this, regardless of whether they attempt to use the function

compiling spl-token 3.5.0 against solana-program 1.15.3:

   Compiling solana-program v1.15.3 (/home/hana/work/solana/solana/sdk/program)
Error: Function _ZN14solana_program4vote5state9VoteState11deserialize17hbbcc05667760d2caE Stack offset of 6344 exceeded max offset of 4096 by 2248 bytes, please minimize large stack variables
Error: Function _ZN229_$LT$solana_program..vote..state..vote_state_0_23_5.._..$LT$impl$u20$serde..de..Deserialize$u20$for$u20$solana_program..vote..state..vote_state_0_23_5..VoteState0_23_5$GT$..deserialize..__Visitor$u20$as$u20$serde..de..Visitor$GT$9visit_seq17h9e7c929fd7b9125cE Stack offset of 5752 exceeded max offset of 4096 by 1656 bytes, please minimize large stack variables
   Compiling spl-token v3.5.0 (/home/hana/work/solana/spl/token/program)

Summary of Changes

gate the function implementation behind #[cfg(not(target_os = "solana"))]. this breaks no downstream consumers (because the function is not usable as-is) and fixes the warning for everyone

we can handroll a parser for this struct that works in a program context if/when one is required, i just wanted to get this in now that 1.16 exists and 1.15 needs to be stabilized

Fixes #30188

@2501babe 2501babe marked this pull request as draft February 24, 2023 21:12
the existing deserialize implementation overruns the sbf stack and is unusable in a program context
this silences a warning to that effect which all solana_program importers receive

closes solana-labs#30188
@2501babe 2501babe force-pushed the 20230204_votestatedeser branch from bd27bef to 754637a Compare February 24, 2023 21:21
@2501babe 2501babe marked this pull request as ready for review February 25, 2023 02:03
Copy link
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this! lgtm
I vote for v1.15 backport, since this stack-size violation affects all v1.15 program-context users.

@2501babe 2501babe added the v1.15 (abandoned) The v1.15 branch has been abandoned label Feb 26, 2023
@2501babe 2501babe merged commit bd49b98 into solana-labs:master Feb 26, 2023
@2501babe 2501babe deleted the 20230204_votestatedeser branch February 26, 2023 00:10
mergify bot pushed a commit that referenced this pull request Feb 26, 2023
the existing deserialize implementation overruns the sbf stack and is unusable in a program context
this silences a warning to that effect which all solana_program importers receive

closes #30188

(cherry picked from commit bd49b98)
2501babe added a commit that referenced this pull request Mar 1, 2023
…30515) (#30532)

remove VoteState::deserialize() from sbf builds (#30515)

the existing deserialize implementation overruns the sbf stack and is unusable in a program context
this silences a warning to that effect which all solana_program importers receive

closes #30188

(cherry picked from commit bd49b98)

Co-authored-by: hana <81144685+2501babe@users.noreply.github.com>
nickfrosty pushed a commit to nickfrosty/solana that referenced this pull request Mar 12, 2023
the existing deserialize implementation overruns the sbf stack and is unusable in a program context
this silences a warning to that effect which all solana_program importers receive

closes solana-labs#30188
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v1.15 (abandoned) The v1.15 branch has been abandoned
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compilation error on solana_program vote state
2 participants