fix(core): handle i64::MIN in PRAGMA cache_size to prevent panic (#5250)#5272
Open
HarshKumarSahni wants to merge 1 commit intotursodatabase:mainfrom
Open
fix(core): handle i64::MIN in PRAGMA cache_size to prevent panic (#5250)#5272HarshKumarSahni wants to merge 1 commit intotursodatabase:mainfrom
HarshKumarSahni wants to merge 1 commit intotursodatabase:mainfrom
Conversation
LeMikaelF
reviewed
Feb 15, 2026
| assert_eq!(*count, 7, "all inserts should have succeeded"); | ||
| } | ||
|
|
||
| #[turso_macros::test(mvcc)] |
Collaborator
There was a problem hiding this comment.
could you please replace this with a new test case in our .sqltest files?
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.
Description
This PR fixes a panic that occurs when
PRAGMA cache_sizeis set toi64::MIN(-9223372036854775808).The issue was caused by an implementation detail where
i64::MIN.abs()was called, resulting in an overflow panic becausei64::MIN's absolute value cannot be represented in a signed 64-bit integer.Changes:
i64::MINby clamping it toi64::MAXbefore processing.Motivation and context
This fixes issue #5250.
Previously, executing
PRAGMA cache_size=-9223372036854775808would crash the database process with an "attempt to negate with overflow" error. This PR ensures the database handles this edge case gracefully instead of crashing.Closes #5250
Description of AI Usage
I utilized the Antigravity AI assistant to help diagnose and resolve this issue.