Skip to content

fix: panics in non-Must* functions#374

Merged
HealthyBuilder merged 1 commit into
solana-foundation:mainfrom
sonicfromnewyoke:sonic/fix-panics-out-must-conv
Apr 3, 2026
Merged

fix: panics in non-Must* functions#374
HealthyBuilder merged 1 commit into
solana-foundation:mainfrom
sonicfromnewyoke:sonic/fix-panics-out-must-conv

Conversation

@sonicfromnewyoke
Copy link
Copy Markdown
Contributor

Problem

SDK code uses panic() in non-Must* functions, meaning any caller - including user application code - could have their process crash with no recovery path:

  • Message.SetVersion() panicked on invalid version instead of returning an error
  • RegisterInstructionDecoder() panicked when a different decoder was already registered for the same program ID
  • Data.String() panicked when the zstd encoder pool returned an error
  • RegisterInstructionDecoder() had a TOCTOU race: the existence check and the registration were two separate locked operations, so a concurrent registration could be silently dropped
  • SetProgramID() across 9 program packages called MustRegisterInstructionDecoder, meaning public runtime API could panic the caller's process

Summary of Changes

  • fixed panics in non-Must* functions with returning error
  • added MustRegisterInstructionDecoder for init() use
  • updated tests

@HealthyBuilder HealthyBuilder merged commit bdd6a7d into solana-foundation:main Apr 3, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants